@@ -11,6 +11,7 @@ plugins {
1111 `java- library`
1212 `java- test- fixtures`
1313 `maven- publish`
14+ `signing`
1415}
1516
1617val repoUrl = " https://github.com/gabrielfeo/gradle-enterprise-api-kotlin"
@@ -172,15 +173,6 @@ tasks.named<Jar>("javadocJar") {
172173 from(tasks.dokkaHtml)
173174}
174175
175- publishing {
176- publications {
177- create<MavenPublication >(" library" ) {
178- artifactId = " gradle-enterprise-api-kotlin"
179- from(components[" java" ])
180- }
181- }
182- }
183-
184176testing {
185177 suites {
186178 getByName<JvmTestSuite >(" test" ) {
@@ -192,7 +184,6 @@ testing {
192184 }
193185 register<JvmTestSuite >(" integrationTest" ) {
194186 dependencies {
195- // implementation(project())
196187 implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1" )
197188 }
198189 }
@@ -229,3 +220,65 @@ dependencies {
229220 implementation(" com.squareup.retrofit2:converter-scalars:2.9.0" )
230221 api(" org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1" )
231222}
223+
224+ publishing {
225+ publications {
226+ create<MavenPublication >(" library" ) {
227+ artifactId = " gradle-enterprise-api-kotlin"
228+ from(components[" java" ])
229+ pom {
230+ name.set(" Gradle Enterprise API Kotlin" )
231+ description.set(" A library to use the Gradle Enterprise REST API in Kotlin" )
232+ url.set(" https://github.com/gabrielfeo/gradle-enterprise-api-kotlin" )
233+ licenses {
234+ license {
235+ name.set(" MIT" )
236+ url.set(" https://spdx.org/licenses/MIT.html" )
237+ distribution.set(" repo" )
238+ }
239+ }
240+ developers {
241+ developer {
242+ id.set(" gabrielfeo" )
243+ name.set(" Gabriel Feo" )
244+ 245+ }
246+ }
247+ scm {
248+ val basicUrl = " github.com/gabrielfeo/gradle-enterprise-api-kotlin"
249+ connection.set(" scm:git:git://$basicUrl .git" )
250+ developerConnection.set(" scm:git:ssh://$basicUrl .git" )
251+ url.set(" https://$basicUrl /" )
252+ }
253+ }
254+ }
255+ }
256+ repositories {
257+ maven {
258+ name = " mavenCentral"
259+ val releasesRepoUrl = uri(" https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" )
260+ val snapshotsRepoUrl = uri(" https://s01.oss.sonatype.org/content/repositories/snapshots/" )
261+ val isSnapshot = version.toString().endsWith(" SNAPSHOT" )
262+ url = if (isSnapshot) snapshotsRepoUrl else releasesRepoUrl
263+ authentication {
264+ register<BasicAuthentication >(" basic" )
265+ }
266+ credentials {
267+ username = project.properties[" maven.central.username" ] as String?
268+ password = project.properties[" maven.central.password" ] as String?
269+ }
270+ }
271+ }
272+ }
273+
274+ fun isCI () = System .getenv(" CI" ).toBoolean()
275+
276+ signing {
277+ sign(publishing.publications[" library" ])
278+ if (isCI()) {
279+ useInMemoryPgpKeys(
280+ project.properties[" signing.secretKey" ] as String? ,
281+ project.properties[" signing.password" ] as String? ,
282+ )
283+ }
284+ }
0 commit comments