You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2026/10/20 01:28:02 UTC
[jira] [Closed] (GROOVY-12199) Replace ant-jarjar with com.gradleup.shadow for package relocation
[ https://issues.apache.org/jira/browse/GROOVY-12199?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-12199.
------------------------------
> 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
> Assignee: Daniel Sun
> Priority: Major
> Fix For: 6.0.0-beta-1
>
>
> 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)