Skip to content

Commit c027799

Browse files
authored
chore: migrating to vanniktech plugin (#276)
* chore: migrating to vanniktech plugin * chore: removed old properties
1 parent d72e2c2 commit c027799

File tree

6 files changed

+50
-86
lines changed

6 files changed

+50
-86
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ jobs:
3838
gpg --quiet --output $GITHUB_WORKSPACE/release.gpg --dearmor ./release.asc
3939
4040
echo "Build and publish"
41-
sed -i -e "s,sonatypeToken=,sonatypeToken=$SONATYPE_TOKEN_USERNAME,g" gradle.properties
41+
sed -i -e "s,mavenCentralUsername=,mavenCentralUsername=$SONATYPE_TOKEN_USERNAME,g" gradle.properties
4242
SONATYPE_TOKEN_PASSWORD_ESCAPED=$(printf '%s\n' "$SONATYPE_TOKEN_PASSWORD" | sed -e 's/[\/&]/\\&/g')
43-
sed -i -e "s,sonatypeTokenPassword=,sonatypeTokenPassword=$SONATYPE_TOKEN_PASSWORD_ESCAPED,g" gradle.properties
43+
sed -i -e "s,mavenCentralPassword=,mavenCentralPassword=$SONATYPE_TOKEN_PASSWORD_ESCAPED,g" gradle.properties
4444
sed -i -e "s,signing.keyId=,signing.keyId=$GPG_KEY_ID,g" gradle.properties
4545
sed -i -e "s,signing.password=,signing.password=$GPG_PASSWORD,g" gradle.properties
4646
sed -i -e "s,signing.secretKeyRingFile=,signing.secretKeyRingFile=$GITHUB_WORKSPACE/release.gpg,g" gradle.properties
4747
env:
48-
GPG_KEY_ARMOR: "${{ secrets.SYNCED_GPG_KEY_ARMOR }}"
48+
GPG_KEY_ARMOR: ${{ secrets.SYNCED_GPG_KEY_ARMOR }}
4949
GPG_KEY_ID: ${{ secrets.SYNCED_GPG_KEY_ID }}
5050
GPG_PASSWORD: ${{ secrets.SYNCED_GPG_KEY_PASSWORD }}
5151
SONATYPE_TOKEN_PASSWORD: ${{ secrets.SONATYPE_TOKEN_PASSWORD }}

.releaserc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ plugins:
1515
to: ":${nextRelease.version}"
1616
- - "@semantic-release/exec"
1717
- prepareCmd: "./gradlew build --warn --stacktrace"
18-
publishCmd: "./gradlew publish --warn --stacktrace"
18+
publishCmd: "./gradlew publishToMavenCentral --warn --stacktrace"
1919
- - "@semantic-release/git"
2020
- assets:
2121
- "build.gradle"

build.gradle

Lines changed: 29 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ buildscript {
3232

3333
plugins {
3434
id "org.jetbrains.dokka" version "1.9.10"
35+
id "com.vanniktech.maven.publish" version "0.34.0" apply false
3536
}
3637

3738

39+
3840
ext.projectArtifactId = { project ->
3941
if (project.name == 'places-ktx') {
4042
return project.name
@@ -43,9 +45,6 @@ ext.projectArtifactId = { project ->
4345
}
4446
}
4547

46-
/**
47-
* Shared configs across subprojects
48-
*/
4948
allprojects {
5049
group = 'com.google.maps.android'
5150
version = '3.3.1'
@@ -60,19 +59,15 @@ allprojects {
6059
}
6160
}
6261

63-
/**
64-
* Publishing and signing info
65-
*/
6662
subprojects { project ->
6763
if (project.ext.artifactId == null) return
6864

6965
plugins.apply(libs.plugins.androidLibrary.get().pluginId)
7066
plugins.apply(libs.plugins.mavenPublish.get().pluginId)
7167
plugins.apply(libs.plugins.dokka.get().pluginId)
7268
plugins.apply(libs.plugins.jacocoAndroid.get().pluginId)
73-
plugins.apply(libs.plugins.signing.get().pluginId)
69+
plugins.apply(libs.plugins.vanniktech.get().pluginId)
7470

75-
// Code coverage
7671
jacoco {
7772
toolVersion = "0.8.7"
7873
}
@@ -82,90 +77,44 @@ subprojects { project ->
8277
jacoco.excludes = ['jdk.internal.*']
8378
}
8479

85-
tasks.register('sourcesJar', Jar) {
86-
from android.sourceSets.main.java.source
87-
archiveClassifier = "sources"
88-
}
80+
mavenPublishing {
81+
publishToMavenCentral()
82+
signAllPublications()
8983

90-
tasks.register('javadocJar', Jar) {
91-
dependsOn(tasks.named("dokkaHtml"))
92-
dependsOn(tasks.named("dokkaJavadoc"))
93-
archiveClassifier.set("javadoc")
94-
from new File(buildDir, "dokka/javadoc")
95-
}
84+
pom {
85+
name = project.name
86+
description = "Kotlin extensions (KTX) for Places SDK for Android"
87+
url = "https://github.com/googlemaps/android-places-ktx"
9688

97-
publishing {
98-
publications {
99-
aar(MavenPublication) {
100-
groupId project.group
101-
artifactId project.ext.artifactId
102-
version project.version
103-
104-
pom {
105-
name = project.name
106-
description = "Kotlin extensions (KTX) for Places SDK for Android"
107-
url = "https://github.com/googlemaps/android-places-ktx"
108-
scm {
109-
connection = 'scm:git@github.com:googlemaps/android-places-ktx.git'
110-
developerConnection = 'scm:git@github.com:googlemaps/android-places-ktx.git'
111-
url = 'https://github.com/googlemaps/android-places-ktx'
112-
}
113-
114-
licenses {
115-
license {
116-
name = 'The Apache Software License, Version 2.0'
117-
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
118-
distribution = 'repo'
119-
}
120-
}
121-
122-
organization {
123-
name = 'Google Inc'
124-
url = 'http://developers.google.com/maps'
125-
}
126-
127-
developers {
128-
developer {
129-
name = 'Google Inc.'
130-
}
131-
}
89+
licenses {
90+
license {
91+
name = "The Apache Software License, Version 2.0"
92+
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
93+
distribution = "repo"
13294
}
95+
}
13396

134-
pom.withXml {
135-
def dependenciesNode = asNode().appendNode('dependencies')
136-
project.configurations.api.allDependencies.each { dependency ->
137-
def dependencyNode = dependenciesNode.appendNode('dependency')
138-
dependencyNode.appendNode('groupId', dependency.group)
139-
dependencyNode.appendNode('artifactId', dependency.name)
140-
dependencyNode.appendNode('version', dependency.version)
141-
}
142-
}
97+
scm {
98+
connection = "scm:git@github.com:googlemaps/android-places-ktx.git"
99+
developerConnection = "scm:git@github.com:googlemaps/android-places-ktx.git"
100+
url = "https://github.com/googlemaps/android-places-ktx"
101+
}
143102

144-
afterEvaluate {
145-
artifact "$buildDir/outputs/aar/$project.name-release.aar"
146-
artifact javadocJar
147-
artifact sourcesJar
148-
}
103+
organization {
104+
name = "Google Inc"
105+
url = "http://developers.google.com/maps"
149106
}
150-
}
151107

152-
repositories {
153-
maven {
154-
name = "mavencentral"
155-
url = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
156-
credentials {
157-
username sonatypeToken
158-
password sonatypeTokenPassword
108+
developers {
109+
developer {
110+
id = "google"
111+
name = "Google Inc."
159112
}
160113
}
161114
}
162115
}
163-
164-
signing {
165-
sign publishing.publications.aar
166-
}
167116
}
168117

169-
tasks.register('clean', Delete) {
118+
tasks.register("clean", Delete) {
170119
delete rootProject.layout.buildDirectory
171120
}

gradle.properties

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,9 @@ signing.keyId=
2626
signing.password=
2727
signing.secretKeyRingFile=
2828

29-
sonatypeToken=
30-
sonatypeTokenPassword=
29+
mavenCentralUsername=
30+
mavenCentralPassword=
31+
32+
# Add a property to enable automatic release to Maven Central (optional, but good for CI)
33+
# If true, publishToMavenCentral will also close and release the staging repository
34+
mavenCentralAutomaticRelease=false

gradle/libs.versions.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ test-core = "1.6.1"
2727
mockito-kotlin = "2.2.0"
2828
junit = "4.13.2"
2929
mockito-core = "5.11.0"
30+
gradleMavenPublishPlugin = "0.34.0"
3031

3132
[libraries]
3233
appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
@@ -55,10 +56,12 @@ test-core = { group = "androidx.test", name = "core", version.ref = "test-core"
5556
mockito-kotlin = { group = "com.nhaarman.mockitokotlin2", name = "mockito-kotlin", version.ref = "mockito-kotlin" }
5657
junit = { group = "junit", name = "junit", version.ref = "junit" }
5758
mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito-core" }
59+
gradle-maven-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "gradleMavenPublishPlugin" }
5860

5961
[plugins]
6062
androidLibrary = { id = "com.android.library" }
6163
mavenPublish = { id = "maven-publish" }
6264
dokka = { id = "org.jetbrains.dokka" }
6365
jacocoAndroid = { id = "com.mxalbert.gradle.jacoco-android" }
6466
signing = { id = "signing" }
67+
vanniktech = { id = "com.vanniktech.maven.publish" }

settings.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
pluginManagement {
2+
repositories {
3+
gradlePluginPortal()
4+
google()
5+
mavenCentral()
6+
}
7+
}
8+
19
include ':app'
210
include ':places-ktx'
311
rootProject.name = "android-places-ktx"

0 commit comments

Comments
 (0)