@@ -38,8 +38,14 @@ plugins {
3838 id " com.grab.sizer.kotlin"
3939 id ' java-gradle-plugin'
4040 alias(libs. plugins. kotlin. dsl)
41+ alias(libs. plugins. gradle. plugin. publish)
42+ id ' maven-publish'
43+ id ' signing'
4144}
4245
46+ group = ' com.grab.sizer'
47+ version = ' 1.0.0-SNAPSHOT'
48+
4349dependencies {
4450 compileOnly libs. android. gradle. plugin
4551 compileOnly libs. android. gradle. api
@@ -55,13 +61,103 @@ dependencies {
5561 testImplementation libs. android. gradle. api
5662}
5763
64+ java {
65+ withJavadocJar()
66+ withSourcesJar()
67+ }
68+
5869gradlePlugin {
70+ website = ' https://grab.github.io/app-sizer/'
71+ vcsUrl = ' https://github.com/grab/app-sizer.git'
72+
5973 plugins {
6074 appSizerPlugin {
6175 id = ' com.grab.sizer'
6276 implementationClass = ' com.grab.plugin.sizer.AppSizerPlugin'
63- displayName = " app-sizer-plugin"
77+ displayName = ' App Sizer Plugin'
78+ description = ' A tool designed to analyze the download size of Android applications'
79+ tags. set([' android' , ' size' , ' analysis' , ' app-size' ])
6480 }
6581 }
6682}
6783
84+ def configurePom (pom ) {
85+ pom. with {
86+ name = ' App Sizer'
87+ description = ' A tool designed to analyze the download size of Android applications'
88+ url = ' https://github.com/grab/app-sizer'
89+
90+ licenses {
91+ license {
92+ name = ' MIT License'
93+ url = ' https://opensource.org/licenses/MIT'
94+ distribution = ' repo'
95+ }
96+ }
97+
98+ developers {
99+ developer {
100+ id = ' grab'
101+ name = ' Grab Engineers'
102+ 103+ organization = ' Grab'
104+ organizationUrl = ' https://github.com/grab'
105+ }
106+ }
107+
108+ scm {
109+ connection = ' scm:git:git://github.com/grab/app-sizer.git'
110+ developerConnection = ' scm:git:ssh://github.com:grab/app-sizer.git'
111+ url = ' https://github.com/grab/app-sizer'
112+ }
113+ }
114+ }
115+
116+ publishing {
117+ publications. withType(MavenPublication ). configureEach { publication ->
118+ if (publication. name == ' pluginMaven' ) {
119+ publication. artifactId = ' sizer-gradle-plugin' // Set the artifact ID
120+ }
121+ configurePom(publication. pom)
122+ }
123+
124+ repositories {
125+ maven {
126+ name = ' sonatype'
127+ def releasesRepoUrl = " https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
128+ def snapshotsRepoUrl = " https://s01.oss.sonatype.org/content/repositories/snapshots/"
129+ url = version. endsWith(' SNAPSHOT' ) ? snapshotsRepoUrl : releasesRepoUrl
130+
131+ credentials {
132+ username = findProperty(' ossrhUsername' ) ?: System . getenv(' OSSRH_USERNAME' )
133+ password = findProperty(' ossrhPassword' ) ?: System . getenv(' OSSRH_PASSWORD' )
134+ }
135+ }
136+ }
137+ }
138+
139+ signing {
140+ def signingKey = findProperty(' signingKey' ) ?: System . getenv(' GPG_PRIVATE_KEY' )
141+ def signingPassword = findProperty(' signingPassword' ) ?: System . getenv(' GPG_PASSPHRASE' )
142+
143+ useInMemoryPgpKeys(signingKey, signingPassword)
144+ sign publishing. publications
145+ }
146+
147+ // Fixed task ordering
148+ tasks. withType(AbstractPublishToMaven ). configureEach { publishTask ->
149+ publishTask. mustRunAfter(tasks. withType(Sign ))
150+ }
151+
152+ tasks. withType(Sign ). configureEach { signTask ->
153+ signTask. onlyIf { ! version. endsWith(' SNAPSHOT' ) }
154+ tasks. withType(AbstractPublishToMaven ). forEach {
155+ it. dependsOn(signTask)
156+ }
157+ }
158+
159+ tasks. register(' publishAll' ) {
160+ group = ' publishing'
161+ description = ' Publishes all publications to all repositories'
162+ dependsOn(tasks. withType(AbstractPublishToMaven ))
163+ }
0 commit comments