[
https://issues.apache.org/jira/browse/GROOVY-12199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18099608#comment-18099608
]
ASF GitHub Bot commented on GROOVY-12199:
-----------------------------------------
paulk-asert commented on PR #2740:
URL: https://github.com/apache/groovy/pull/2740#issuecomment-5099648237
AI read of differences, others don't seem to matter:
> Bucket 4a — Java9.class in the grooid jar · the one genuine semantic
divergence
>
> The grooid relocation maps java.beans.** → groovyjarjaropenbeans, and
shadow rewrote a string literal "java.beans" → "groovyjarjaropenbeans" in
Java9.JAVA8_PACKAGES(). jarjar left it intact. That array (source comment:
"should NOT be changed!") holds real JDK package names looked up against
ModuleFinder.ofSystem() to decide which packages Groovy opens reflectively —
"groovyjarjaropenbeans" isn't a real JDK package, so that lookup would no-op.
> - Scope: grooid (Android) jar only — the core jar's Java9.class is
byte-identical.
> - Real-world impact: very likely inert (the Java9 plugin's static init
needs java.lang.module, which doesn't exist on Android, so it won't load
there). But it's an unintended bytecode change and the clearest example of
shadow's more aggressive string-constant rewriting. Worth flagging to Daniel —
ideally the java.beans.** grooid rule should suppress string-literal relocation
(or the AutoComplete case too), to keep grooid bytecode faithful.
> Replace ant-jarjar with com.gradleup.shadow for package relocation
> ------------------------------------------------------------------
>
> Key: GROOVY-12199
> URL: https://issues.apache.org/jira/browse/GROOVY-12199
> Project: Groovy
> Issue Type: Improvement
> Reporter: Daniel Sun
> Priority: Major
>
> h2. Motivation
> Published Groovy jars shade ASM, the ANTLR runtime, and picocli into packages
> under the {{groovyjarjar}} prefix so those libraries do not clash with
> application-chosen versions on the classpath.
> Today that shading is driven by {{com.eed3si9n.jarjar:ant-jarjar}} through an
> Ant {{taskdef}} in {{{}JarJarTask{}}}. The tool is no longer the maintained
> mainstream for Gradle package relocation; {{com.gradleup.shadow}} is. This
> change swaps the engine while {*}keeping the published jar surface
> compatible{*}.
> h2. Goals
> * Replace ant-jarjar with {{com.gradleup.shadow}}
> ({{{}shadow-gradle-plugin{}}} 9.6.1) for package relocation.
> * Preserve published-artefact behaviour:
> ** {{groovyjarjar}} package prefixes (e.g. {{{}groovyjarjarasm{}}},
> {{{}groovyjarjarantlr4{}}}, {{{}groovyjarjarpicocli{}}})
> ** OSGi manifest generation (BND via the root {{osgi}} extension)
> ** {{META-INF/INDEX.LIST}} and fixed timestamps for reproducible builds
> ** {{untouchedFiles}} (e.g. {{CliBuilder}} classes that must not be
> relocated)
> * Rename build machinery so names match the tool and the existing
> {{repackagedDependencies}} DSL:
> ** {{JarJarTask}} → {{RepackageJarTask}}
> ** task {{jarjar}} → {{repackageJar}}
> * Drop the {{tools}} dependency on ant-jarjar and the {{jarjar}} entry in
> {{{}versions.properties{}}}; refresh {{{}gradle/verification-metadata.xml{}}}.
> h2. Non-goals / compatibility contract
> * *Do not* rename {{groovyjarjar}} packages — they are part of the published
> binary surface.
> * *Do not* rename distribution license/notice snippets such as
> {{LICENSE-JARJAR}} / {{NOTICE-JARJAR}} — those describe the *contents* of the
> shaded artefact, not the build engine.
> * Build-only rename: task and class names change; consumers of published
> jars are unaffected.
> h2. Approach
> * Introduce {{RepackageJarTask}} extending Shadow's {{{}ShadowJar{}}}.
> * Feed only the base jar ({{{}inputJar{}}}) plus explicitly selected
> {{{}repackagedLibraries{}}}; never pull the whole {{runtimeClasspath}} into
> the shade.
> * Keep compact relocation patterns at call sites (e.g. {{org.antlr}} →
> {{{}groovyjarjarantlr4{}}}) and convert them to Shadow prefix relocations
> inside the task.
> * Post-process the shaded jar: re-add {{{}untouchedFiles{}}}, write
> {{{}INDEX.LIST{}}}, optionally rewrite the OSGi manifest.
> * Update call sites: convention plugins,
> {{{}GroovyLibraryExtension.withGrooid{}}}, binary-compatibility, servlet
> {{{}javaxJar{}}}, jmx / concurrent-java / osgi-test / groovydoc wiring.
> * Document the new task name in {{ARCHITECTURE.md}} and
> {{{}COMPATIBILITY.md{}}}.
> h2. Implementation notes
> ||Before||After||
> |{{JarJarTask}} extends {{DefaultTask}} + Ant jarjar
> {{taskdef}}|{{RepackageJarTask}} extends {{ShadowJar}}|
> |Task name {{jarjar}}|Task name {{repackageJar}}|
> |{{tools}} dep on
> ant-jarjar|{{com.gradleup.shadow:shadow-gradle-plugin:9.6.1}} in
> {{build-logic}}|
> |{{versions.jarjar}}|removed|
> |{{from}} / {{outputFile}} / {{createManifest}} / …|{{inputJar}} /
> {{archiveFile}} / {{generateOsgiManifest}} / {{sourceExcludes}}|
> Overlapping shaded dependency entries (e.g. antlr4-runtime vs
> antlr4-annotations) use {{DuplicatesStrategy.EXCLUDE}} on
> {{RepackageJarTask}} so the shade is first-wins rather than WARN/duplicate.
> h2. Verification
> * {{./gradlew :repackageJar :groovy-json:repackageJar
> :groovy-servlet:javaxJar :grooidJar}} succeeds.
> * Shaded jars still contain {{groovyjarjar}} classes,
> {{{}META-INF/INDEX.LIST{}}}, and OSGi headers as before.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)