This is an automated email from the ASF dual-hosted git repository.

ajantha pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new 9253391  Catalog Migrator: Configure Apache Maven publishing (#135)
9253391 is described below

commit 92533919400a904423ec7589962f4e42358d88b3
Author: Ajantha Bhat <[email protected]>
AuthorDate: Sat Jan 31 07:33:36 2026 +0800

    Catalog Migrator: Configure Apache Maven publishing (#135)
    
    Add support for publishing artifacts to Apache Nexus repository with proper 
Maven Central metadata and signing capabilities.
    
    Changes:
    - Add nexus-publish-plugin to root `build.gradle.kts` with Apache 
repository configuration supporting both environment variables and Gradle 
properties
    - Create `publishing.kt` with Maven publication setup including:
      * Proper POM metadata (licenses, SCM, mailing lists, issue tracking)
      * Support for publishing shadow JARs (CLI module)
      * Conditional signing for release builds (-Prelease flag)
      * Source and Javadoc JAR generation for non-shadow modules
    - Configure build-conventions to apply publishing to all projects
    - Update CLI module to apply shadow plugin
    
    The configuration supports:
    - Local testing: `./gradlew publishToMavenLocal`
    - Apache release: `./gradlew publishToApache -Prelease -PuseGpgAgent`
    - Staging management: `./gradlew closeAndReleaseApacheStagingRepository`
    
    Published artifacts:
    - org.apache.polaris.tools:iceberg-catalog-migrator-api (with sources, 
javadoc)
    - org.apache.polaris.tools:iceberg-catalog-migrator-api-test (with sources, 
javadoc)
    - org.apache.polaris.tools:iceberg-catalog-migrator-cli (shadow JAR)
---
 iceberg-catalog-migrator/build.gradle.kts          |  36 ++++++-
 .../src/main/kotlin/build-conventions.gradle.kts   |   3 +
 .../buildSrc/src/main/kotlin/publishing.kt         | 117 +++++++++++++++++++++
 iceberg-catalog-migrator/cli/build.gradle.kts      |   2 -
 iceberg-catalog-migrator/settings.gradle.kts       |   2 +-
 5 files changed, 155 insertions(+), 5 deletions(-)

diff --git a/iceberg-catalog-migrator/build.gradle.kts 
b/iceberg-catalog-migrator/build.gradle.kts
index 4e4a2b4..e4189b4 100644
--- a/iceberg-catalog-migrator/build.gradle.kts
+++ b/iceberg-catalog-migrator/build.gradle.kts
@@ -17,13 +17,13 @@
  * under the License.
  */
 
+import java.net.URI
 import org.nosphere.apache.rat.RatTask
 
 plugins {
-  `maven-publish`
-  signing
   `build-conventions`
   alias(libs.plugins.rat)
+  alias(libs.plugins.nexus.publish.plugin)
 }
 
 spotless {
@@ -77,3 +77,35 @@ tasks.named<RatTask>("rat").configure {
   // Rat can't scan binary images
   excludes.add("**/*.png")
 }
+
+// Pass environment variables:
+//    ORG_GRADLE_PROJECT_apacheUsername
+//    ORG_GRADLE_PROJECT_apachePassword
+// OR in ~/.gradle/gradle.properties set
+//    apacheUsername
+//    apachePassword
+// Call targets:
+//    publishToApache
+//    closeApacheStagingRepository
+//    releaseApacheStagingRepository
+//       or closeAndReleaseApacheStagingRepository
+//
+// Username is your ASF ID
+// Password: your ASF LDAP password - or better: a token generated via
+// https://repository.apache.org/
+nexusPublishing {
+  transitionCheckOptions {
+    // default==60 (10 minutes), wait up to 120 minutes
+    maxRetries = 720
+    // default 10s
+    delayBetween = java.time.Duration.ofSeconds(10)
+  }
+
+  repositories {
+    register("apache") {
+      nexusUrl = URI.create("https://repository.apache.org/service/local/";)
+      snapshotRepositoryUrl =
+        
URI.create("https://repository.apache.org/content/repositories/snapshots/";)
+    }
+  }
+}
diff --git 
a/iceberg-catalog-migrator/buildSrc/src/main/kotlin/build-conventions.gradle.kts
 
b/iceberg-catalog-migrator/buildSrc/src/main/kotlin/build-conventions.gradle.kts
index 4be6e6b..c2a5188 100644
--- 
a/iceberg-catalog-migrator/buildSrc/src/main/kotlin/build-conventions.gradle.kts
+++ 
b/iceberg-catalog-migrator/buildSrc/src/main/kotlin/build-conventions.gradle.kts
@@ -39,3 +39,6 @@ if (hasSrcMain || hasSrcTest) {
     configureTestTasks()
   }
 }
+
+// Configure publishing for all projects
+configurePublishing()
diff --git a/iceberg-catalog-migrator/buildSrc/src/main/kotlin/publishing.kt 
b/iceberg-catalog-migrator/buildSrc/src/main/kotlin/publishing.kt
new file mode 100644
index 0000000..d29f9bb
--- /dev/null
+++ b/iceberg-catalog-migrator/buildSrc/src/main/kotlin/publishing.kt
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
+import org.gradle.api.Project
+import org.gradle.api.publish.PublishingExtension
+import org.gradle.api.publish.maven.MavenPublication
+import org.gradle.kotlin.dsl.apply
+import org.gradle.kotlin.dsl.configure
+import org.gradle.kotlin.dsl.create
+import org.gradle.kotlin.dsl.get
+import org.gradle.kotlin.dsl.the
+import org.gradle.kotlin.dsl.withType
+import org.gradle.plugins.signing.SigningExtension
+import org.gradle.plugins.signing.SigningPlugin
+
+fun Project.configurePublishing() {
+  // Skip publishing for the root project
+  if (project == rootProject) {
+    return
+  }
+
+  apply(plugin = "maven-publish")
+  apply<SigningPlugin>()
+
+  val isSigningEnabled = project.hasProperty("release") || 
project.hasProperty("signArtifacts")
+
+  afterEvaluate {
+    configure<PublishingExtension> {
+      publications {
+        create<MavenPublication>("maven") {
+          val hasShadowJar = tasks.findByName("shadowJar") != null
+
+          if (hasShadowJar) {
+            // Publish shadow JAR instead of regular JAR
+            // Note: applyShadowJar() already sets archiveClassifier to ""
+            tasks.withType<ShadowJar>().configureEach { artifact(this) }
+          } else {
+            // Only add java component if shadow JAR doesn't exist
+            pluginManager.withPlugin("java") { from(components["java"]) }
+          }
+
+          groupId = project.group.toString()
+          artifactId = project.name
+          version = project.version.toString()
+
+          pom {
+            name.set("Apache Polaris Tools(incubating) - Iceberg Catalog 
Migrator")
+            description.set("Iceberg Catalog Migrator from Apache Polaris 
Tools")
+            url.set("https://polaris.apache.org/";)
+            inceptionYear.set("2024")
+
+            licenses {
+              license {
+                name.set("Apache-2.0") // SPDX identifier
+                url.set("https://www.apache.org/licenses/LICENSE-2.0.txt";)
+              }
+            }
+
+            mailingLists {
+              mailingList {
+                name.set("Dev Mailing List")
+                post.set("[email protected]")
+                subscribe.set("[email protected]")
+                unsubscribe.set("[email protected]")
+              }
+            }
+
+            issueManagement {
+              system.set("Github")
+              url.set("https://github.com/apache/polaris-tools/issues";)
+            }
+
+            scm {
+              
connection.set("scm:git:https://github.com/apache/polaris-tools.git";)
+              
developerConnection.set("scm:git:https://github.com/apache/polaris-tools.git";)
+              url.set("https://github.com/apache/polaris-tools";)
+            }
+          }
+        }
+      }
+    }
+
+    // Configure signing following Apache Polaris pattern
+    if (isSigningEnabled) {
+      configure<SigningExtension> {
+        val signingKey = project.findProperty("signingKey") as String?
+        val signingPassword = project.findProperty("signingPassword") as 
String?
+        useInMemoryPgpKeys(signingKey, signingPassword)
+
+        val publishing = the<PublishingExtension>()
+        sign(publishing.publications["maven"])
+
+        // Support gpg-agent if useGpgAgent property is set
+        if (project.hasProperty("useGpgAgent")) {
+          useGpgCmd()
+        }
+      }
+    }
+  }
+}
diff --git a/iceberg-catalog-migrator/cli/build.gradle.kts 
b/iceberg-catalog-migrator/cli/build.gradle.kts
index 8330a77..c097e3d 100644
--- a/iceberg-catalog-migrator/cli/build.gradle.kts
+++ b/iceberg-catalog-migrator/cli/build.gradle.kts
@@ -21,8 +21,6 @@ import 
com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
 
 plugins {
   `java-library`
-  `maven-publish`
-  signing
   alias(libs.plugins.nessie.run)
   `build-conventions`
 }
diff --git a/iceberg-catalog-migrator/settings.gradle.kts 
b/iceberg-catalog-migrator/settings.gradle.kts
index 72a71b0..5e32c0f 100644
--- a/iceberg-catalog-migrator/settings.gradle.kts
+++ b/iceberg-catalog-migrator/settings.gradle.kts
@@ -22,7 +22,7 @@ val baseVersion = file("version.txt").readText().trim()
 rootProject.name = "polaris-iceberg-catalog-migrator"
 
 gradle.beforeProject {
-  group = "org.apache.polaris.tools"
+  group = "org.apache.polaris.tools.iceberg-catalog-migrator"
   version = baseVersion
   description =
     when (name) {

Reply via email to