|
| 1 | +/* |
| 2 | + * Copyright (c) 2026 dexpace and Omar Aljarrah |
| 3 | + * |
| 4 | + * Licensed under the MIT License. See LICENSE in the project root. |
| 5 | + * SPDX-License-Identifier: MIT |
| 6 | + */ |
| 7 | + |
| 8 | +// Convention plugin for every module that is published to Maven Central. It carries the |
| 9 | +// `maven-publish` + `signing` setup, the shared POM metadata, the staging repository, and the |
| 10 | +// CI-gated signing configuration that was previously copied verbatim into all nine module |
| 11 | +// build scripts. |
| 12 | +// |
| 13 | +// A module opts in with `plugins { id("dexpace.published-module") }`. The publication name, |
| 14 | +// coordinates, POM, repository, and signing behaviour are then identical across modules; the |
| 15 | +// `name`/`description` fields derive from `project.name`, so a module needs no further |
| 16 | +// publishing configuration. A module that must NOT be published simply does not apply this |
| 17 | +// plugin. |
| 18 | + |
| 19 | +plugins { |
| 20 | + `maven-publish` |
| 21 | + signing |
| 22 | +} |
| 23 | + |
| 24 | +// Coordinates. The group and version are the same for every published module and match the |
| 25 | +// 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. |
| 27 | +group = "org.dexpace" |
| 28 | +version = "0.0.1-alpha.1" |
| 29 | + |
| 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") |
| 43 | + } |
| 44 | + } |
| 45 | + developers { |
| 46 | + developer { |
| 47 | + id.set("dexpace") |
| 48 | + name.set("Dexpace SDK Team") |
| 49 | + } |
| 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") |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 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")) |
| 64 | + } |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 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) |
| 74 | + } |
| 75 | + sign(publishing.publications["library"]) |
| 76 | +} |
0 commit comments