@@ -20,11 +20,15 @@ plugins {
2020 id(" com.adarshr.test-logger" )
2121 id(" org.jetbrains.dokka" )
2222 `maven- publish`
23+ signing
2324}
2425
2526val androidEnabled = project.findProperty(" android" )?.toString()?.toBoolean() == true
2627val release = project.findProperty(" release" )?.toString()?.toBoolean() == true
27- val githubPublish = project.findProperty(" githubPublish" )?.toString()?.toBoolean() == true
28+
29+ // If the publication is meant to be done on a remote repository (GitHub packages or Maven central).
30+ // Modifying this property will affect the release workflows!
31+ val isRemotePublication = project.findProperty(" remotePublication" )?.toString()?.toBoolean() == true
2832
2933var buildMode = if (release) BuildMode .RELEASE else BuildMode .DEBUG
3034
@@ -74,7 +78,7 @@ kotlin {
7478 }
7579 }
7680 val jvmMain by getting {
77- if (githubPublish ) {
81+ if (isRemotePublication ) {
7882 // The line below is intended to load the native libraries that are crosscompiled on GitHub actions when publishing a JVM package.
7983 resources.srcDir(" ../jni-libs" ).include(" */**" )
8084 } else {
@@ -89,7 +93,39 @@ kotlin {
8993
9094 publishing {
9195 publications.withType<MavenPublication > {
96+ groupId = " org.eclipse.zenoh"
97+ artifactId = " zenoh-java"
9298 version = project.version.toString() + if (project.hasProperty(" SNAPSHOT" )) " -SNAPSHOT" else " "
99+
100+ pom {
101+ name.set(" Zenoh Java" )
102+ description.set(" The Eclipse Zenoh: Zero Overhead Pub/sub, Store/Query and Compute." )
103+ url.set(" https://zenoh.io/" )
104+
105+ licenses {
106+ license {
107+ name.set(" Eclipse Public License 2.0 OR Apache License 2.0" )
108+ url.set(" http://www.eclipse.org/legal/epl-2.0" )
109+ }
110+ }
111+ developers {
112+ developer {
113+ id.set(" ZettaScale" )
114+ name.set(" ZettaScale Zenoh Team" )
115+ 116+ }
117+ developer {
118+ id.set(" DariusIMP" )
119+ name.set(" Darius Maitia" )
120+ 121+ }
122+ }
123+ scm {
124+ connection.set(" scm:git:https://github.com/eclipse-zenoh/zenoh-java.git" )
125+ developerConnection.set(" scm:git:https://github.com/eclipse-zenoh/zenoh-java.git" )
126+ url.set(" https://github.com/eclipse-zenoh/zenoh-java" )
127+ }
128+ }
93129 }
94130
95131 repositories {
@@ -101,10 +137,32 @@ kotlin {
101137 password = System .getenv(" GITHUB_TOKEN" )
102138 }
103139 }
140+ maven {
141+ name = " MavenCentral"
142+ url = uri(if (project.hasProperty(" SNAPSHOT" ))
143+ " https://oss.sonatype.org/content/repositories/snapshots/"
144+ else
145+ " https://oss.sonatype.org/service/local/staging/deploy/maven2/"
146+ )
147+ credentials {
148+ username = System .getenv(" ORG_OSSRH_USERNAME" )
149+ password = System .getenv(" ORG_OSSRH_PASSWORD" )
150+ }
151+ }
104152 }
105153 }
106154}
107155
156+ signing {
157+ isRequired = isRemotePublication
158+ useInMemoryPgpKeys(System .getenv(" ORG_GPG_SUBKEY_ID" ), System .getenv(" ORG_GPG_PRIVATE_KEY" ), System .getenv(" ORG_GPG_PASSPHRASE" ))
159+ sign(publishing.publications)
160+ }
161+
162+ tasks.withType<PublishToMavenRepository >().configureEach {
163+ dependsOn(tasks.withType<Sign >())
164+ }
165+
108166tasks.withType<Test > {
109167 doFirst {
110168 // The line below is added for the Android Unit tests which are equivalent to the JVM tests.
@@ -125,7 +183,7 @@ tasks.named("compileKotlinJvm") {
125183
126184tasks.register(" buildZenohJni" ) {
127185 doLast {
128- if (! githubPublish ) {
186+ if (! isRemotePublication ) {
129187 // This is intended for local publications. For publications done through GitHub workflows,
130188 // the zenoh-jni build is achieved and loaded differently from the CI
131189 buildZenohJNI(buildMode)
0 commit comments