Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resources file in META-INF folder - conflict between shadded and not-shadded files. #906

Open
mosaikdoc opened this issue Feb 19, 2024 · 0 comments

Comments

@mosaikdoc
Copy link

Please check the User Guide before submitting "how do I do 'x'?" questions!

Shadow Version

6.1.0

Gradle Version

7.5.1

Expected Behavior

  • Shadded META-INF/axiom.xml relocated contents (loader).
  • Shadded META-INF/axiom.xml relocated contents (xmlns for conflict avoiding).
  • Shadded java class ImplementationFactory with content modified for use shadded META-INF/axiom.xml relocated xmlns value.

Actual Behavior

Due to version conflict, I need to shade/relocate axiom-api and axiom-impl jars.
Using com.github.johnrengelman.shadow (v6.1.0), with the following build.gradle :

plugins {
    id 'com.github.johnrengelman.shadow' version '6.1.0'
    id 'java'
}
repositories {
    flatDir { dirs 'lib'}
    ...
}
dependencies {
    implementation fileTree(dir: 'lib', include: 'axiom*.jar')
    ...
}
shadowJar {
    relocate('org.apache.axiom','eu.shadow.apache.axiom')
    ...
}

the classes have been relocated correctly, but 3 problems remain:

1 - META-INF/axiom.xml (from axiom-impl) contents have not been replaced :

<implementations xmlns="http://ws.apache.org/axiom/">
    <implementation name="llom" loader="org.apache.axiom.om.impl.llom.factory.OMLinkedListMetaFactoryLoader">
        <feature name="default" priority="100"/>
    </implementation>
</implementations>

I need to relocate his loader to "eu.shadow.apache.axiom.om.impl.llom.factory.OMLinkedListMetaFactoryLoader".

2 - Two META-INF/axiom.xml files are in conflict (shadded and non-shadded). This files offers a resource with the same qualified name (see below). I need to "relocate" xmlns to "http://ws.apache.shadow.eu/axiom/" for conflict avoiding.

3 - For resource use, class "org.apache.axiom.locator.ImplementationFactory" (axiom-impl) defines :
private static final String NS = "http://ws.apache.org/axiom/";
I need that shadded "eu.shadow.apache.axiom.locator.ImplementationFactory" "relocates" this value to :
private static final String NS = "http://ws.apache.shadow.eu/axiom/
in order to reach the desired relocated resource.

Is it possible to do this with the Shadow plugin?

Many thanks.

NOTE : I made all these modifications by hand, with text and hexa editors, directly on the output shadow jar, and it works. I modified axiom.xml and ImplementationFactory.class files.

Gradle Build Script(s)

GIST : https://gist.github.com/mosaikdoc/5c4a293ea0d6b939e3d165aff1dd8e4e

Content of Shadow JAR (jar tf <jar file> - post link to GIST if too long)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant