Skip to content

Commit 42d12b1

Browse files
committed
update vanniktech publish plugin to 1.21.0 and use the new .base plugin
1 parent 7e9caa8 commit 42d12b1

File tree

3 files changed

+71
-12
lines changed

3 files changed

+71
-12
lines changed
Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
import com.android.build.gradle.TestedExtension
2-
import com.squareup.workflow1.library
3-
import com.squareup.workflow1.libsCatalog
1+
@file:Suppress("UnstableApiUsage")
2+
3+
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
4+
import com.vanniktech.maven.publish.JavadocJar.Dokka
5+
import com.vanniktech.maven.publish.KotlinJvm
6+
import com.vanniktech.maven.publish.KotlinMultiplatform
7+
import com.vanniktech.maven.publish.MavenPublishBaseExtension
48
import com.vanniktech.maven.publish.SonatypeHost
59

610
plugins {
711
id("org.jetbrains.dokka")
8-
id("com.vanniktech.maven.publish")
12+
id("com.vanniktech.maven.publish.base")
913
// track all runtime classpath dependencies for anything we ship
1014
id("dependency-guard")
1115
}
1216

13-
group = project.property("GROUP") as String
1417
version = project.property("VERSION_NAME") as String
1518

16-
mavenPublish {
17-
sonatypeHost = SonatypeHost.S01
18-
}
19-
2019
tasks.register("checkVersionIsSnapshot") {
2120
doLast {
2221
val expected = "-SNAPSHOT"
@@ -26,3 +25,62 @@ tasks.register("checkVersionIsSnapshot") {
2625
}
2726
}
2827
}
28+
29+
configure<MavenPublishBaseExtension> {
30+
publishToMavenCentral(SonatypeHost.S01)
31+
// Will only apply to non snapshot builds.
32+
signAllPublications()
33+
// import all settings from root project and project-specific gradle.properties files
34+
pomFromGradleProperties()
35+
36+
val artifactId = project.property("POM_ARTIFACT_ID") as String
37+
val pomDescription = project.property("POM_NAME") as String
38+
39+
pluginManager.withPlugin("com.android.library") {
40+
configure(AndroidSingleVariantLibrary(sourcesJar = true))
41+
setPublicationProperties(pomDescription, artifactId)
42+
}
43+
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
44+
configure(KotlinJvm(javadocJar = Dokka(taskName = "dokkaGfm"), sourcesJar = true))
45+
setPublicationProperties(pomDescription, artifactId)
46+
}
47+
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
48+
configure(KotlinMultiplatform(javadocJar = Dokka(taskName = "dokkaGfm")))
49+
// don't set the artifactId for KMP, because this is handled by the KMP plugin itself
50+
setPublicationProperties(pomDescription, artifactIdOrNull = null)
51+
}
52+
}
53+
54+
fun setPublicationProperties(
55+
pomDescription: String,
56+
artifactIdOrNull: String?
57+
) {
58+
// This has to be inside an `afterEvaluate { }` because these publications are created lazily,
59+
// using the project's `name`, which is just the directory name instead of the actual artifact id.
60+
// We can't set `name` because it's immutable, so we have to wait until the publication is
61+
// created, then overwrite the incorrect value.
62+
afterEvaluate {
63+
configure<PublishingExtension> {
64+
publications.filterIsInstance<MavenPublication>()
65+
.forEach { publication ->
66+
67+
if (artifactIdOrNull != null) {
68+
publication.artifactId = artifactIdOrNull
69+
}
70+
publication.pom.description.set(pomDescription)
71+
72+
// Note that we're setting the `groupId` of this specific publication,
73+
// and not `Project.group`. By default, `Project.group` is a project's parent,
74+
// so for example the group of `:workflow-ui:compose` is `workflow-ui`. If we set every
75+
// project's `group` to the group id, then we use the natural disambiguation of unique
76+
// paths. For instance, projects with paths of `:lib1:core` and `:lib2:core`
77+
// and a group of `com.example` would both have the coordinates of `com.example:core`.
78+
publication.groupId = project.property("GROUP") as String
79+
}
80+
}
81+
}
82+
}
83+
84+
tasks.withType(PublishToMavenRepository::class.java).configureEach {
85+
notCompatibleWithConfigurationCache("See https://github.com/gradle/gradle/issues/13468")
86+
}

dependencies/classpath.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ com.google.testing.platform:core-proto:0.0.8-alpha07
6666
com.googlecode.java-diff-utils:diffutils:1.3.0
6767
com.googlecode.json-simple:json-simple:1.1
6868
com.googlecode.juniversalchardet:juniversalchardet:1.0.3
69-
com.squareup.moshi:moshi:1.12.0
69+
com.squareup.moshi:moshi:1.13.0
7070
com.squareup.okhttp3:okhttp:3.14.9
7171
com.squareup.okio:okio:2.10.0
7272
com.squareup.retrofit2:converter-moshi:2.9.0
@@ -77,7 +77,8 @@ com.squareup:kotlinpoet:1.3.0
7777
com.sun.activation:javax.activation:1.2.0
7878
com.sun.istack:istack-commons-runtime:3.0.8
7979
com.sun.xml.fastinfoset:FastInfoset:1.2.16
80-
com.vanniktech:gradle-maven-publish-plugin:0.18.0
80+
com.vanniktech:gradle-maven-publish-plugin:0.21.0
81+
com.vanniktech:nexus:0.21.0
8182
commons-codec:commons-codec:1.10
8283
commons-io:commons-io:2.4
8384
commons-logging:commons-logging:1.2

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ squareup-workflow = "1.0.0"
8181

8282
timber = "4.7.1"
8383
truth = "1.1.3"
84-
vanniktech-publish = "0.18.0"
84+
vanniktech-publish = "0.21.0"
8585

8686
[plugins]
8787

0 commit comments

Comments
 (0)