|
1 | 1 | import org.gradle.jvm.tasks.Jar |
2 | 2 | import org.jetbrains.kotlin.gradle.dsl.JvmTarget |
| 3 | +import java.util.* |
3 | 4 |
|
4 | 5 | plugins { |
5 | | - kotlin("multiplatform") |
6 | | - kotlin("plugin.serialization") |
7 | | - id("org.jetbrains.kotlinx.kover") |
8 | | - id("org.jetbrains.kotlinx.binary-compatibility-validator") |
9 | | - `maven-publish-convention` |
| 6 | + alias(libs.plugins.kotlin) |
| 7 | + alias(libs.plugins.kotlin.serialization) |
| 8 | + alias(libs.plugins.kotlinx.kover) |
| 9 | + alias(libs.plugins.kotlinx.binary.compatibility.validator) |
| 10 | + `maven-publish` |
| 11 | + signing |
10 | 12 | } |
11 | 13 |
|
12 | 14 | allprojects { |
@@ -90,3 +92,75 @@ tasks.getByName("compileJava9Java", JavaCompile::class) { |
90 | 92 | targetCompatibility = "1.9" |
91 | 93 | sourceCompatibility = "1.9" |
92 | 94 | } |
| 95 | + |
| 96 | +publishing { |
| 97 | + repositories { |
| 98 | + maven { |
| 99 | + name = "Central" |
| 100 | + afterEvaluate { |
| 101 | + url = if (version.toString().endsWith("SNAPSHOT")) { |
| 102 | + // uri("https://s01.oss.sonatype.org/content/repositories/snapshots") |
| 103 | + uri("https://oss.sonatype.org/content/repositories/snapshots") |
| 104 | + } else { |
| 105 | + // uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2") |
| 106 | + uri("https://oss.sonatype.org/service/local/staging/deploy/maven2") |
| 107 | + } |
| 108 | + } |
| 109 | + |
| 110 | + credentials { |
| 111 | + username = properties["ossrhUsername"]?.toString() ?: System.getenv("OSSRH_USERNAME") |
| 112 | + password = properties["ossrhPassword"]?.toString() ?: System.getenv("OSSRH_PASSWORD") |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + publications { |
| 117 | + withType<MavenPublication> { |
| 118 | + val pubName = name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else "$it" } |
| 119 | + afterEvaluate { |
| 120 | + val emptyJavadocJar by tasks.register<org.gradle.api.tasks.bundling.Jar>("emptyJavadocJar$pubName") { |
| 121 | + archiveClassifier = "javadoc" |
| 122 | + archiveBaseName = artifactId |
| 123 | + } |
| 124 | + artifact(emptyJavadocJar) |
| 125 | + } |
| 126 | + pom { |
| 127 | + name.set("kotlinx-serialization-bencoding") |
| 128 | + description.set("A Kotlin serialization codec for bencoding format.") |
| 129 | + url.set("https://github.com/iseki0/kotlinx-serialization-bencoding") |
| 130 | + licenses { |
| 131 | + license { |
| 132 | + name.set("Apache-2.0") |
| 133 | + url.set("https://www.apache.org/licenses/LICENSE-2.0") |
| 134 | + } |
| 135 | + } |
| 136 | + developers { |
| 137 | + developer { |
| 138 | + id.set("iseki0") |
| 139 | + name.set("iseki zero") |
| 140 | + |
| 141 | + } |
| 142 | + } |
| 143 | + scm { |
| 144 | + connection.set("scm:git:https://github.com/iseki0/kotlinx-serialization-bencoding.git") |
| 145 | + developerConnection.set("scm:git:https://github.com/iseki0/kotlinx-serialization-bencoding.git") |
| 146 | + url.set("https://github.com/iseki0/kotlinx-serialization-bencoding") |
| 147 | + } |
| 148 | + } |
| 149 | + } |
| 150 | + } |
| 151 | +} |
| 152 | + |
| 153 | +afterEvaluate { |
| 154 | + signing { |
| 155 | + // To use local gpg command, configure gpg options in ~/.gradle/gradle.properties |
| 156 | + // reference: https://docs.gradle.org/current/userguide/signing_plugin.html#example_configure_the_gnupgsignatory |
| 157 | + useGpgCmd() |
| 158 | + publishing.publications.forEach { sign(it) } |
| 159 | + } |
| 160 | +} |
| 161 | + |
| 162 | +tasks.withType<AbstractArchiveTask>().configureEach { |
| 163 | + isPreserveFileTimestamps = false |
| 164 | + isReproducibleFileOrder = true |
| 165 | +} |
| 166 | + |
0 commit comments