lhotari opened a new pull request, #25409:
URL: https://github.com/apache/pulsar/pull/25409
### Motivation
Running `./gradlew assemble` twice showed 8 tasks re-executing every time
instead of being UP-TO-DATE. The `shadowJar` task (with `archiveClassifier =
""`) produces a JAR with the same filename as the standard `jar` task, causing
`shadowJar` to overwrite `jar`'s output. On the next build, Gradle detects
`jar`'s output as changed and re-runs both tasks — a rebuild cycle on every
invocation.
Additionally, the 9 shadow modules used 3 different patterns for artifact
exposure (`shadowElements` custom configuration, per-module
`runtimeElements`/`apiElements` replacement, and direct task refs), leading to
inconsistent and duplicated build logic.
### Modifications
**Build cache fix:**
- Disable the `jar` task for all shadow modules (it conflicts with
`shadowJar` output)
- Replace `runtimeElements`/`apiElements` outgoing artifacts with
`shadowJar` so plain `project()` dependencies resolve to the shadow jar
- Clear secondary `classes` variants (Gradle prefers these over the jar for
compilation, but they point to empty directories for source-less shadow modules)
**Convention plugins (new `buildSrc/`):**
- `pulsar.shadow-conventions` — base plugin for all shadow modules: applies
the shadow plugin, disables jar, sets `archiveClassifier = ""`, calls
`mergeServiceFiles()`, and replaces outgoing artifacts
- `pulsar.client-shade-conventions` — extends the base for client shade
modules (`pulsar-client-shaded`, `pulsar-client-admin-shaded`,
`pulsar-client-all`): configures all shared dependency includes, file excludes,
relocations, and filesMatching blocks. Modules now only define their project
dependencies
- `PulsarShadeUtils.kt` — helper functions: `relocateWithPrefix()` reduces
boilerplate for the common `relocate("x.y", "$prefix.x.y")` pattern, and
`relocateAsyncHttpClientProperties()` fixes the ahc-default.properties package
name replacement
**Removed `shadowElements`:**
- The custom `shadowElements` configuration is no longer needed since
`runtimeElements`/`apiElements` now serve the shadow jar directly
- Consumers switched from `configuration = "shadowElements"` to plain
`project()` dependencies
**Bug fix:**
- Fixed `localrun-shaded`'s ahc-default.properties `filesMatching` which
hardcoded `org.apache.pulsar.shade` instead of using its own `shadePrefix`
(`org.apache.pulsar.functions.runtime.shaded`)
**Normalized inconsistencies across client shade modules:**
- `com.yahoo` relocate: standardized to broad `com.yahoo` pattern
- `org.eclipse.jetty` relocate target: standardized to `org.eclipse.jetty`
- Added missing includes/relocates to shared convention (harmless when deps
aren't on classpath)
### Verifying this change
This change is already covered by existing tests, such as:
- Running `./gradlew assemble` twice verifies build caching (second run: 179
up-to-date, 0 executed)
- Shade test compilation (`pulsar-client-shade-test`,
`pulsar-client-admin-shade-test`, `pulsar-client-all-shade-test`) verifies
artifact resolution
- `tiered-storage-jcloud:compileJava` verifies jclouds-shaded consumed
correctly via plain `project()`
### Does this pull request potentially affect one of the following parts:
- [ ] Dependencies (add or upgrade a dependency)
- [ ] The public API
- [ ] The schema
- [ ] The default values of configurations
- [ ] The threading model
- [ ] The binary protocol
- [ ] The REST endpoints
- [ ] The admin CLI options
- [ ] The metrics
- [ ] Anything that affects deployment
### Documentation
- [x] `doc-not-needed`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]