I have a git module project using maven and wicket and imported in IntelliJ. I have also in a module, one test trying to test to load all classes present in dependencies used by the project to check if there is no encoding error in file *.properties (and other tasks). When i launch it directly from Intellij(green play button close to the test name), the test is working and all classes from all dependencies are loaded, but when i launch with
mvn clean install
in terminal or from maven toolbar only classes in current project are loaded.
i tried all classloader possibilities but each time same result, with maven command only class in target/classes of current project are loaded in Classloader
this is my test
@Test
void testCheckMistakesInProperties() throws Exception {
var iter = Reflections.class.getClassLoader().getResources( "" ).asIterator();
//var iter = ClassLoader.getPlatformClassLoader().getResources( "" ).asIterator();
//var iter2 = ClassLoader.getSystemClassLoader().getResources( "" ).asIterator();
//var iter3 = AllWicketPagesTest.class.getClassLoader().getResources( "" ).asIterator();
while(iter.hasNext()){
var url = iter.next();
Path resourcesPath;;
try{
resourcesPath = Path.of( url.toURI() );
}catch(FileSystemNotFoundException e){
continue;
}
try( var pathStream = java.nio.file.Files.walk( resourcesPath ) ){
pathStream.forEach( path -> {
var pathStr = path.toString();
LOGGER.info( "Properties file checked {}", pathStr ); });
}catch(Exception e){
continue;
}
}
}
i tried all method (classLoader Helper etc...) nothing working
here my pom.xml
<dependencies>
<dependency>
<groupId>es.lib</groupId>
<artifactId>webapp</artifactId>
</dependency>
<dependency>
<groupId>es.java</groupId>
<artifactId>entities</artifactId>
</dependency>
<dependency>
<groupId>es.java</groupId>
<artifactId>entities</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.lib</groupId>
<artifactId>stockmarket</artifactId>
</dependency>
<dependency>
<groupId>com.java.intranet</groupId>
<artifactId>intranet-web</artifactId>
</dependency>
<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>wicketstuff-html5</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>bootstrap-tourist</artifactId>
</dependency>
<dependency>
<groupId>com.java</groupId>
<artifactId>base-entities</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.java</groupId>
<artifactId>web</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-inmemory</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.icegreen</groupId>
<artifactId>greenmail-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency><!-- To provide the annotation processor in the IDE's classpath -->
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>Clean test database before the tests</id>
<phase>process-test-resources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
It is a complicated project with a lot of parent pom, but i think only in this project we can fix the issue i want to be able to see in classloader classes from es.java lib or com.java
I think also with intellij it uses the project structure link to load dependencies classes(present as a submodule in editor)
even if i use a class from lib and retrieve classloader it will load only the current project (where my test is launched) to load only target/classes classes and not form jar or external lib/dependencies
