Reputation: 27822
When updating the pom.xml
file to use the newer maven-compiler-version
, 3.6.0
and passing the -D=maven.test.skip=true
option, tests compilation is actually not skipped.
Based on the following sample POM below:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sample</groupId>
<artifactId>sample-compiler</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
</project>
While setting the maven-compiler-plugin
version to the previous 3.5.1
would effectively skip test compilation when invoking:
mvn clean test -Dmaven.test.skip=true
Would produce:
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ sample-compiler ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ sample-compiler ---
[INFO] Tests are skipped.
However, when upgrading it to 3.6.0
and invoking the same command as above, we would have:
[INFO] --- maven-compiler-plugin:3.6.0:testCompile (default-testCompile) @ sample-compiler ---
[INFO] Not compiling test sources
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\data\eclipse-workspace\sample-compiler\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ sample-compiler ---
[INFO] Tests are skipped.
Note the additional Changes detected - recompiling the module!
meaning that the maven.test.skip
flag was actually ignored.
Question: is that a regression or is something missing in the process above?
Upvotes: 1
Views: 2353
Reputation: 27822
While trying to post it as a bug report, I actually found it was already reported:
MCOMPILER-284
: maven.test.skip
doesn't skip test compilationSo it is probably a regression, to be further confirmed by the Maven team.
Important to note: the same behavior happens when passing the skip
test to the testCompile
goal (executed by default via default bindings), as following (overriding its default id, default-testCompile
):
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>default-testCompile</id>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Solutions: To fix this issue
3.5.1
, or3.6.1
, now availableUpvotes: 2