@@ -23,54 +23,65 @@ plugins {
2323
2424// Coordinates. The group and version are the same for every published module and match the
2525// values declared on the root project; keeping the single literal here makes a coordinate
26- // change a one-file edit instead of a nine-file edit.
26+ // change a one-file edit instead of a nine-file edit. The root `build.gradle.kts` still declares
27+ // its own `group`/`version`, so a version bump must update both literals until they are sourced
28+ // from one place (e.g. a `gradle.properties` entry read by both).
2729group = " org.dexpace"
2830version = " 0.0.1-alpha.1"
2931
30- publishing {
31- publications {
32- create<MavenPublication >(" library" ) {
33- from(components[" java" ])
34- pom {
35- name.set(project.name)
36- description.set(" Dexpace Java SDK — ${project.name} " )
37- url.set(" https://github.com/dexpace/java-sdk" )
38- licenses {
39- license {
40- name.set(" MIT License" )
41- url.set(" https://github.com/dexpace/java-sdk/blob/main/LICENSE" )
42- distribution.set(" repo" )
32+ // The `library` publication is built from the `java` software component, which only exists once a
33+ // `java`/`java-library`/`kotlin("jvm")` plugin is applied. Every current consumer applies
34+ // `kotlin("jvm")`, but this plugin neither applies nor requires one, so the whole publication +
35+ // signing setup is guarded on the Kotlin JVM plugin. Without the guard, a module that opted in
36+ // without a Java/Kotlin plugin would fail with an opaque "SoftwareComponent with name java not
37+ // found".
38+ pluginManager.withPlugin(" org.jetbrains.kotlin.jvm" ) {
39+ publishing {
40+ publications {
41+ create<MavenPublication >(" library" ) {
42+ from(components[" java" ])
43+ pom {
44+ name.set(project.name)
45+ description.set(" Dexpace Java SDK — ${project.name} " )
46+ url.set(" https://github.com/dexpace/java-sdk" )
47+ licenses {
48+ license {
49+ name.set(" MIT License" )
50+ url.set(" https://github.com/dexpace/java-sdk/blob/main/LICENSE" )
51+ distribution.set(" repo" )
52+ }
4353 }
44- }
45- developers {
46- developer {
47- id.set(" dexpace" )
48- name.set(" Dexpace SDK Team" )
54+ developers {
55+ developer {
56+ id.set(" dexpace" )
57+ name.set(" Dexpace SDK Team" )
58+ }
59+ }
60+ scm {
61+ connection.set(" scm:git:https://github.com/dexpace/java-sdk.git" )
62+ developerConnection.set(" scm:git:ssh://github.com/dexpace/java-sdk.git" )
63+ url.set(" https://github.com/dexpace/java-sdk" )
4964 }
50- }
51- scm {
52- connection.set(" scm:git:https://github.com/dexpace/java-sdk.git" )
53- developerConnection.set(" scm:git:ssh://github.com/dexpace/java-sdk.git" )
54- url.set(" https://github.com/dexpace/java-sdk" )
5565 }
5666 }
5767 }
58- }
59- repositories {
60- // Local staging repository. CI must override this to publish to a real remote.
61- maven {
62- name = " local "
63- url = uri(rootProject.layout.buildDirectory.dir( " staging-repo " ))
68+ repositories {
69+ // Local staging repository. CI must override this to publish to a real remote.
70+ maven {
71+ name = " local "
72+ url = uri(rootProject.layout.buildDirectory.dir( " staging-repo " ))
73+ }
6474 }
6575 }
66- }
6776
68- signing {
69- isRequired = (System .getenv(" CI" ) == " true" )
70- val signingKey = project.findProperty(" signing.key" ) as String? ? : System .getenv(" SIGNING_KEY" )
71- val signingPassword = project.findProperty(" signing.password" ) as String? ? : System .getenv(" SIGNING_PASSWORD" )
72- if (! signingKey.isNullOrBlank() && ! signingPassword.isNullOrBlank()) {
73- useInMemoryPgpKeys(signingKey, signingPassword)
77+ signing {
78+ isRequired = (System .getenv(" CI" ) == " true" )
79+ val signingKey = project.findProperty(" signing.key" ) as String? ? : System .getenv(" SIGNING_KEY" )
80+ val signingPassword =
81+ project.findProperty(" signing.password" ) as String? ? : System .getenv(" SIGNING_PASSWORD" )
82+ if (! signingKey.isNullOrBlank() && ! signingPassword.isNullOrBlank()) {
83+ useInMemoryPgpKeys(signingKey, signingPassword)
84+ }
85+ sign(publishing.publications[" library" ])
7486 }
75- sign(publishing.publications[" library" ])
7687}
0 commit comments