The below code is able to scan all the dependencies and load the resources when I am executing it from IntelliJ as IntelliJ resolves dependencies from the .m2 repo, but it's not able to load anything when running from the fat jar created by shade. any help?
The below code is not producing any output when executed from shade plugin, while from eclipse it is printing all the relevant properties.
ClassLoader str = ClassLoader.getSystemClassLoader();
try {
Enumeration<URL> resURLs = str.getResources("properties/sample/i18n-resources.properties");
while (resURLs.hasMoreElements()) {
URL resURL = (URL) resURLs.nextElement();
System.out.println("file path : " + resURL.getFile());
}
}
catch (Exception e){
System.out.println("resource exception");
}
pom file :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.sample.extract.samples.SampleClient</mainClass>
</transformer>
</transformers>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedArtifactId>application</shadedArtifactId>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>