howto disable compile of modules when tests are skipepd
In our "big build" (40+ modules), we have several modules that contain only tests.
When I give -DskiptTests to mvn, the tests are not executed.开发者_高级运维
But they are compiled, which costs up to a minute of build time.
How can I selectively turn off such modules when the option skipTests is set?
You'd have to organize your root pom such that the test modules are activated via a profile, and instead of using -Dmaven.test.skip
to turn use -P!testProfile
to deactivate them and hence skipping 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 haven't actually tried that... it should in theory work. I seem to remember that the <skip>
configuration is on all plugins.
Just to clarify the Gareth David point:
- When you run
mvn ... -DskipTests
, only the execution of tests is skipped. This is the same behavior if you runmvn ... -Dtest=notest
- When you run
mvn ... -Dmaven.skip.test=true
, then both test execution and compilation are skipped.
So the second command is enough, without any modification of your pom.xml
file.
(source)
精彩评论