Maven - Skip building test classes

Is there an easy way not to create test classes?

mvn clean install -Dmaven.test.skip=true 

Walter

+44
maven-2
Apr 07 2018-10-17T00:
source share
5 answers

According to the documentation on the Maven Surefire plugin, -Dmaven.test.skip should skip both compilation and test execution. In contrast, -DskipTests simply skips the execution of the test: the tests are still compiling.

+69
Apr 7 '10 at 15:43
source share

Just to be explicit:

skipTests will compile everything in <testSourceDirectory> , but will not execute them.

maven.test.skip will NOT compile any tests, but WILL will execute any compiled tests that <testOutputDirectory> into <testOutputDirectory> .

Thus, the behavior of the above 2 is the opposite. Just wanted to indicate that maven.test.skip does not skip compilation and execution if the test files are unpacked / copied / etc. in <testOutputDirectory> .

In addition, depending on which version of Maven you are using, also maven.test.skip.exec=true , which additionally skips test execution similar to skipTests.

+13
Jun 25 '12 at 18:37
source share

Run a phase that does not include test-compile , such as compile .

 mvn clean compile 
+7
Apr 07 '10 at 15:37
source share

I am not an expert in maven, but what I use in my current project is:

 mvn clean install -DskipTests=true 

Depending on your use case:

 mvn compile -DskipTests=true 

may work for you too.

+5
May 20 '13 at 22:54
source share

It seems that maven-compiler-plugin does not provide a parameter to skip compilation of test sources. I found a workaround in another question that actually overrides plugin execution by adding the following snippet to your pom.xml:

 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <executions> <execution> <id>default-testCompile</id> <phase>none</phase> </execution> </executions> </plugin> </plugins> </build> 

This seems to work, but it definitely does not disable the phase, but disables the default actions that the plugin defines on a specific phase.

0
Nov 28 '17 at 4:31 on
source share



All Articles