duplicate file if try to build with another snakeyaml deps
if someone try to build it with anything that already use snakeyaml (eg. quarkus) than duplicate warning will be got during build:
Dependencies with duplicate files detected. The dependencies [org.yaml:snakeyaml::jar:2.0[paths: /home/lfarkas/.gradle/caches/modules-2/files-2.1/org.yaml/snakeyaml/2.0/3aab2116756442bf0d4cd1c089b24d34c3baa253/snakeyaml-2.0.jar;], io.prometheus.jmx:jmx_prometheus_javaagent::jar:0.18.0[paths: /home/lfarkas/.gradle/caches/modules-2/files-2.1/io.prometheus.jmx/jmx_prometheus_javaagent/0.18.0/889ad8ac7b516a751b50a2a7ce82f611d34f8376/jmx_prometheus_javaagent-0.18.0.jar;]] contain duplicate files, e.g. META-INF/versions/9/org/yaml/snakeyaml/internal/Logger$Level.class
the bigger problem happened during execution of such projects since it produce this error:
Exception in thread "main" java.lang.NoClassDefFoundError: io/prometheus/jmx/shaded/org/yaml/snakeyaml/internal/Logger (wrong name: org/yaml/snakeyaml/internal/Logger)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at org.yaml.snakeyaml.TypeDescription.<clinit>(TypeDescription.java:43)
at org.yaml.snakeyaml.constructor.Constructor.<init>(Constructor.java:60)
at org.yaml.snakeyaml.constructor.Constructor.<init>(Constructor.java:50)
at org.yaml.snakeyaml.Yaml.<init>(Yaml.java:73)
at io.smallrye.config.source.yaml.YamlConfigSource.<clinit>(YamlConfigSource.java:47)
at io.quarkus.config.yaml.runtime.ApplicationYamlConfigSourceLoader.loadConfigSource(ApplicationYamlConfigSourceLoader.java:27)
at io.smallrye.config.AbstractLocationConfigSourceLoader.addConfigSource(AbstractLocationConfigSourceLoader.java:236)
at io.smallrye.config.AbstractLocationConfigSourceLoader.addConfigSource(AbstractLocationConfigSourceLoader.java:231)
at io.smallrye.config.AbstractLocationConfigSourceLoader$ConfigSourcePathConsumer.accept(AbstractLocationConfigSourceLoader.java:329)
at io.smallrye.config.AbstractLocationConfigSourceLoader$ConfigSourcePathConsumer.accept(AbstractLocationConfigSourceLoader.java:316)
at io.smallrye.common.classloader.ClassPathUtils.lambda$consumeAsPath$0(ClassPathUtils.java:103)
at io.smallrye.common.classloader.ClassPathUtils.processAsPath(ClassPathUtils.java:144)
at io.smallrye.common.classloader.ClassPathUtils.consumeAsPath(ClassPathUtils.java:102)
at io.smallrye.common.classloader.ClassPathUtils.consumeAsPaths(ClassPathUtils.java:86)
at io.smallrye.config.AbstractLocationConfigSourceLoader.tryClassPath(AbstractLocationConfigSourceLoader.java:139)
at io.smallrye.config.AbstractLocationConfigSourceLoader.loadConfigSources(AbstractLocationConfigSourceLoader.java:102)
at io.smallrye.config.AbstractLocationConfigSourceLoader.loadConfigSources(AbstractLocationConfigSourceLoader.java:85)
at io.quarkus.config.yaml.runtime.ApplicationYamlConfigSourceLoader$InClassPath.getConfigSources(ApplicationYamlConfigSourceLoader.java:35)
at io.quarkus.config.yaml.runtime.ApplicationYamlConfigSourceLoader$InClassPath.getConfigSources(ApplicationYamlConfigSourceLoader.java:30)
at io.smallrye.config.SmallRyeConfig$ConfigSources.buildSources(SmallRyeConfig.java:581)
at io.smallrye.config.SmallRyeConfig$ConfigSources.<init>(SmallRyeConfig.java:537)
at io.smallrye.config.SmallRyeConfig.<init>(SmallRyeConfig.java:69)
at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:623)
at io.quarkus.runtime.generated.Config.<clinit>(Unknown Source)
at io.quarkus.runner.ApplicationImpl.<clinit>(Unknown Source)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:70)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
This appears to be related to https://issues.apache.org/jira/browse/MSHADE-439
The maven-shade-plugin declaration for jmx_prometheus_javaagent can be changed to filter the classes. This should resolve the issue, but it's not clear on the overall impact on other applications.
<filters>
<filter>
<artifact>org.yaml:snakeyaml</artifact>
<excludes>
<exclude>META-INF/versions/9/org/yaml/snakeyaml/internal/**</exclude>
</excludes>
</filter>
</filters>
I'll have to do some more research/integration testing.
@lfarkas Can you create a simple GitHub project that I can clone and reproduce the issue?