Repository navigation
[cleanup] PIP-463: Migrate build system from Maven to Gradle - #25398
Conversation
- ShutdownUtil: detect Gradle test JVMs and use System.exit instead of Runtime.halt to allow proper Gradle test cleanup - JavaInstanceDepsTest: adapt jar path detection for Gradle output layout - PulsarClusterMetadataSetup: fix driver registration and error logging - SchemaUtil: handle missing Gradle-specific schema exceptions - PerformanceConsumer/Producer/Transaction: fix static counter leaks and timing issues in performance tests - ConnectionTimeoutTest: fix flaky latch count - OpenTelemetryServiceTest: force GC pressure for reliable metric test - SaslAuthenticateTest: increase timeout for Gradle test environment - PulsarBatchSourceE2ETest/PulsarSourceE2ETest: increase builtin test timeouts and fix E2E test configuration - OffsetsCacheTest: adjust TTL for Gradle test timing - BKCluster/PulsarMetadataBookieDriver: fix metadata driver initialization - PulsarStandalone/Starter: minor compatibility adjustments - SimpleTypedProducerConsumerTest: fix URL pattern for NAR directory
Complete Gradle build system for Apache Pulsar, replacing Maven for all CI builds, tests, and distribution packaging. Build system: - Gradle build scripts for all modules with version catalog - Enforced platform module (pulsar-dependencies) for consistent dependency version management across all modules - Shadow JAR configurations for shaded client/admin/all JARs with proper relocation of asynchttpclient properties files - NAR packaging for all IO connectors and tiered storage offloaders - Server, shell, and IO distribution tarballs matching Maven output - Integration and system test infrastructure with testcontainers CI: - GitHub Actions workflows converted from Maven to Gradle - Develocity build scan integration - Test grouping matching Maven surefire configuration - Shade tests on Java 17/21/24 - System tests for IO connectors, functions, schema, tiered storage Key technical decisions: - Shade tests use files(shadowJar) for relocated classes with API modules as separate dependencies (not bundled in shadow JARs) - Kinesis KPL shaded project forces protobuf 4.29.0 (relocated, no runtime conflict) since KPL requires protobuf 4.x - jclouds-shaded bundles Guice 7.0.0 and Jakarta EE 10+ APIs (jakarta.annotation, jakarta.ws.rs, jakarta.inject) required by jclouds 2.6.0, isolated from Pulsar's javax-era versions - Global NAR exclusions for platform modules and protobuf (provided by java-instance.jar at runtime) - Conditional shade test project includes to avoid implicit parent project conflicts
Restore the check-binary-license.sh step that was in the Maven CI: - In build-and-license-check: verify server distribution tarball - In pulsar-test-latest-version-image: verify both server and shell distribution tarballs after Docker image build
Run Trivy vulnerability scan on the pulsar Docker image after build, matching the Maven CI setup. Only runs on apache/pulsar master (not on PRs or forks). Results are uploaded to GitHub Security tab.
Set add-job-summary: always on all Setup Gradle steps so the Develocity build scan URL appears in every job's summary page, not just on failures.
The upstream grpc bump (apache#25353) changed go.mod to require Go 1.24.0. Update the Docker build to use golang:1.24-alpine matching Maven's configuration.
The apache org requires third-party actions to use specific approved commit SHAs, not version tags. Pin to the latest approved SHA from apache/infrastructure-actions.
|
Please update the build instructions in README.md |
Yes, there are several followup cleanup tasks. One other is the |
lhotari
left a comment
There was a problem hiding this comment.
Some initial commits, will continue with remaining
- Rename ci-maven-cache-update.yaml to ci-gradle-cache-update.yaml - Pin gradle/actions/setup-gradle to SHA in codeql and flaky workflows - Remove surefire-reports references from CI (Gradle uses build/reports) - Upgrade Gradle wrapper to 9.4.1 - Move protobuf and develocity plugin versions to libs.versions.toml - Filter Confluent Maven repo to io.confluent.* dependencies only - Add comment about settings.gradle.kts plugin version sync
Rename project names in settings.gradle.kts so Gradle project names match Maven artifactIds automatically, eliminating name-mapping hacks in distribution builds: - :pulsar-client -> :pulsar-client-original (dir: pulsar-client/) - :pulsar-client-admin -> :pulsar-client-admin-original (dir: pulsar-client-admin/) - :pulsar-functions:pulsar-functions-local-runner -> :pulsar-functions:pulsar-functions-local-runner-original (dir: pulsar-functions/localrun/) All project() references updated across 37 build files. Distribution name mappings for these three projects removed. Also fix Confluent repo content filter regex to match both "io.confluent" and "io.confluent.xxx" groups.
Create a Gradle java-platform module that publishes a BOM (Bill of
Materials) listing all Pulsar modules. Users import this to ensure
aligned versions across pulsar-client-api, pulsar-client, etc:
implementation(enforcedPlatform("org.apache.pulsar:pulsar-bom:X.Y.Z"))
This replaces the Maven pulsar-bom POM that was generated by
src/gen-pulsar-bom.sh. The Gradle version uses project() references
so it's always in sync with the actual modules.
The Shadow plugin's filesMatching { filter { } } lambdas (used for
ahc-default.properties content relocation) capture Gradle script
references that can't be serialized by the configuration cache.
Add comments explaining this in the CI workflow and test runner script.
Replace rootProject.tasks.named() cross-project task references with proper Gradle configuration-based artifact sharing. The root project now exposes the filtered BK test jar as a consumable configuration, and consumers depend on it via: project(path = ":", configuration = "filteredBkServerTestJar") This makes the dependency visible to Gradle's task graph, caching, and up-to-date checks.
Simplify IO and offloader distribution build scripts by extracting the project list into a val and using forEach for NAR collection. Note: The NAR plugin doesn't register proper Gradle variants for artifact resolution, so configuration-based NAR collection (artifactType = "nar") doesn't work yet. Keep the dependsOn + from() pattern for now; this can be improved when the NAR plugin supports variant-aware publishing.
The NAR plugin v0.1.2 registers .nar files as outgoing variants on runtimeElements with artifactType = "nar". Distribution builds now use Gradle's artifact view to resolve NAR files through proper dependency resolution instead of direct path references with manual dependsOn — Gradle handles task ordering, caching, and parallel safety automatically.
Both :pulsar-io:pulsar-io-jdbc:postgres and :pulsar-io:pulsar-io-debezium:postgres had Gradle project name "postgres" with group "org.apache.pulsar", causing Gradle to deduplicate them (resolving debezium:postgres → jdbc:postgres). Fix by using qualified project names in settings.gradle.kts (e.g., pulsar-io-jdbc-postgres, pulsar-io-debezium-postgres). Same fix for "core" sub-modules which had the same clash. Skip the archive name convention for projects whose name already starts with the parent name (already qualified).
Let the gradle/actions/setup-gradle action handle Develocity configuration via its injection mechanism. This ensures the access key format is handled correctly regardless of whether the org-level secret uses the server-prefixed format or bare token. Remove the Develocity plugin from settings.gradle.kts and version catalog, and enable injection with develocity-url in all workflows.
…OM entries conditional Move pulsar-client-shaded, pulsar-client-admin-shaded, and pulsar-client-all includes into the core modules section since the BOM references them unconditionally. Use findProject() for modules that are only available in full builds (athenz, localrun-shaded, tiered-storage) to avoid build failures when using -PcoreModules.
lhotari
left a comment
There was a problem hiding this comment.
Some more comments, will continue reviewing
- Replace findProperty() with providers.gradleProperty() in Docker build scripts for configuration cache compatibility - Move hardcoded amazon-kinesis-client:3.1.2 to version catalog as amazon-kinesis-client-v3
lhotari
left a comment
There was a problem hiding this comment.
I have reviewed all changes up to this point.
I guess that resolving the Netty native library shading is one of the most important things to address unless you already solved that.
…mpat, worker deps - Replace all findProperty() with providers.gradleProperty() for configuration cache compatibility (items 21, 27) - Relocate Netty native library filenames in all shaded JARs to avoid conflicts with unshaded Netty (item 23) - Replace shell commands (hostname, date) with pure Java in pulsar-common version generation for Windows compatibility (item 25) - Use dependency configurations instead of cross-project task references in pulsar-functions-worker tests (item 28)
There was a problem hiding this comment.
Good job!
We can solve maven publishing in a separate PR.
For example, comparing the local deployment of maven (mvn deploy -DaltDeploymentRepository=local-repo::file:./local-repo) with gradle's similar results.
publishing {
repositories {
maven {
name = "localTest" // <-- "LocalTest" becomes the repository name
url = uri(layout.buildDirectory.dir("repo"))
}
}
}
and then ./gradlew publishAllPublicationsToLocalTestRepository
We'd also need to get rid of the conditionals in settings.gradle.kts since that causes problems in IDE and adds unnecessary complications. It shouldn't be needed in Gradle builds and is just a leftover from the maven build logic.
UPDATE: I added a comment in #25398 (comment) regarding the conditionals in settings.gradle.kts and why they are unnecessary since gradle provides a great way to achieve what is needed.
# Conflicts: # pulsar-client-messagecrypto-bc/pom.xml
|
Yes, this is just the starting point, that will allow development not to be interrupted. There are still remaining tasks needed and a lot of improvement opportunities. |
Yes, let's get this merged and start iterating. There's a great Gradle cache that would be useful for pull requests. With the solution only changed modules would required to be compiled, checked and so on. It's coming from an Apache Calcite maintainer and the action is already is already approved. https://github.com/marketplace/actions/gradle-cache#sample-integrations |
Summary
Complete migration of Apache Pulsar's build system from Maven to Gradle, as proposed in PIP-463.
What this PR does:
build.gradle.kts,settings.gradle.kts,gradle/libs.versions.toml) for all modulespom.xml,mvnw,.mvn/)pulsar-dependencies) for consistent dependency versionsVerified equivalence with Maven:
PoC PR with full CI green: merlimat#16
Test plan
docdoc-requireddoc-not-neededdoc-complete