maven-shade-plugin
maven-shade-plugin copied to clipboard
[MSHADE-439] Relocate does not relocate the other JVM variants in Multi Release jar.
Niels Basjes opened MSHADE-439 and commented
The 2.0 release of snakeyaml is a Multi Release jar (See this commit). For 2 class files they actually package a standard and a java 9 variant of the same thing.
$ unzip -l ~/.m2/repository/org/yaml/snakeyaml/2.0/snakeyaml-2.0.jar | fgrep Logger
1545 2023-02-26 11:06 META-INF/versions/9/org/yaml/snakeyaml/internal/Logger$Level.class
1365 2023-02-26 11:06 META-INF/versions/9/org/yaml/snakeyaml/internal/Logger.class
1446 2023-02-26 11:06 org/yaml/snakeyaml/internal/Logger$Level.class
1264 2023-02-26 11:06 org/yaml/snakeyaml/internal/Logger.class
When I use the maven-shade-plugin 3.4.1 (latest at the time of writing) to shade this dependency in my project and relocate (!) it to a different package the final jar contains this:
1678 2023-02-26 11:06 META-INF/versions/9/org/yaml/snakeyaml/internal/Logger$Level.class
1484 2023-02-26 11:06 META-INF/versions/9/org/yaml/snakeyaml/internal/Logger.class
1579 2023-02-26 11:06 nl/basjes/shaded/org/yaml/snakeyaml/internal/Logger$Level.class
1383 2023-02-26 11:06 nl/basjes/shaded/org/yaml/snakeyaml/internal/Logger.class
Note that the standard variants have been shaded correctly and the java 9 variants have not been relocated at all.
Affects: 3.4.1
Attachments:
- pom.xml (3.32 kB)
1 votes, 3 watchers
Niels Basjes commented
The attached pom.xml is the smallest reproduction I could make.
- Put in empty directory
- mvn package
- unzip -l target/relocate-0.jar | fgrep Logger
This is the output:
1678 2023-02-26 11:06 META-INF/versions/9/org/yaml/snakeyaml/internal/Logger$Level.class
1484 2023-02-26 11:06 META-INF/versions/9/org/yaml/snakeyaml/internal/Logger.class
1579 2023-02-26 11:06 nl/basjes/shaded/org/yaml/snakeyaml/internal/Logger$Level.class
1383 2023-02-26 11:06 nl/basjes/shaded/org/yaml/snakeyaml/internal/Logger.class