|
| 1 | +import java.util.Properties |
| 2 | + |
1 | 3 | plugins { |
2 | 4 | alias(libs.plugins.kotlinJvm) |
3 | 5 | `java-gradle-plugin` |
4 | 6 | alias(libs.plugins.ktlint) |
5 | 7 | alias(libs.plugins.detekt) |
6 | 8 | `maven-publish` |
| 9 | + signing |
7 | 10 | } |
8 | 11 |
|
9 | 12 | ktlint { |
@@ -42,6 +45,67 @@ publishing { |
42 | 45 | publications.withType<MavenPublication>().configureEach { |
43 | 46 | artifactId = property("ARTIFACT_ID").toString() |
44 | 47 | } |
| 48 | + |
| 49 | + publications { |
| 50 | + create<MavenPublication>("mavenCentral") { |
| 51 | + from(components["java"]) |
| 52 | + |
| 53 | + groupId = property("GROUP").toString() |
| 54 | + artifactId = property("ARTIFACT_ID").toString() |
| 55 | + version = property("VERSION").toString() |
| 56 | + |
| 57 | + pom { |
| 58 | + name.set(property("DISPLAY_NAME").toString()) |
| 59 | + description.set(property("DESCRIPTION").toString()) |
| 60 | + url.set(property("GITHUB_URL").toString()) |
| 61 | + |
| 62 | + licenses { |
| 63 | + license { |
| 64 | + name.set("The MIT License") |
| 65 | + url.set("https://opensource.org/licenses/MIT") |
| 66 | + distribution.set("repo") |
| 67 | + } |
| 68 | + } |
| 69 | + developers { |
| 70 | + developer { |
| 71 | + id.set("callstack") |
| 72 | + name.set("Callstack Team") |
| 73 | + email.set("it-admin@callstack.com") |
| 74 | + } |
| 75 | + } |
| 76 | + scm { |
| 77 | + connection.set(property("SCM_CONNECTION").toString()) |
| 78 | + developerConnection.set(property("SCM_DEV_CONNECTION").toString()) |
| 79 | + url.set(property("GITHUB_URL").toString()) |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + repositories { |
| 86 | + maven { |
| 87 | + name = "MavenCentral" |
| 88 | + url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") // Maven Central URL |
| 89 | + |
| 90 | + credentials { |
| 91 | + username = findProperty("mavenCentralUsername") as String? ?: "" |
| 92 | + password = findProperty("mavenCentralToken") as String? ?: "" |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | +} |
| 97 | + |
| 98 | + |
| 99 | +val localProperties = Properties().apply { |
| 100 | + file("local.properties").takeIf { it.exists() }?.inputStream()?.use { load(it) } |
| 101 | +} |
| 102 | + |
| 103 | +signing { |
| 104 | + useInMemoryPgpKeys( |
| 105 | + localProperties.getProperty("signingKey"), // GPG private key |
| 106 | + localProperties.getProperty("signingPassword") // Passphrase |
| 107 | + ) |
| 108 | + sign(publishing.publications["mavenCentral"]) // Sign the Maven publication |
45 | 109 | } |
46 | 110 |
|
47 | 111 | repositories { |
|
0 commit comments