Howto disable module compilation when skipepd tests

In our "large assembly" (40+ modules), we have several modules that contain only tests.

When I pass -DskiptTests to mvn, tests fail.

But they are compiled, which costs up to a minute of build time.

How can I selectively disable such modules when the skipTests option is set?

+4
source share
2 answers

You will need to organize the root pump so that the test modules are activated through the profile and instead of -Dmaven.test.skip to enable -P!testProfile to disable them and therefore skip them.

Another thought is that you could just do:

 <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <skip>${maven.test.skip}</skip> </configuration> </plugin> </plugins> 

I actually have not tried this ... it should theoretically work. I seem to remember that the <skip> configuration is in all plugins.

+2
source

Just to clarify Gareth David's point:

  • When mvn ... -DskipTests only tests are skipped. This is the same behavior if you run mvn ... -Dtest=notest
  • When you run mvn ... -Dmaven.skip.test=true , skip both the test execution and compilation.

So, the second command is enough, without any changes to your pom.xml file.

( source )

+1
source

All Articles