【发布时间】:2017-03-18 13:52:58
【问题描述】:
当更新pom.xml 文件以使用较新的maven-compiler-version、3.6.0 并传递-D=maven.test.skip=true 选项时,实际上并没有跳过测试编译。
基于以下示例 POM:
<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>
虽然将maven-compiler-plugin 版本设置为之前的3.5.1 会在调用时有效地跳过测试编译:
mvn clean test -Dmaven.test.skip=true
会产生:
[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.
但是,当将其升级到 3.6.0 并调用与上述相同的命令时,我们会:
[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.
注意额外的Changes detected - recompiling the module! 意味着maven.test.skip 标志实际上被忽略了。
问题:这是回归还是上述过程中缺少什么?
【问题讨论】:
-
也在MCOMPILER-284 中报告。也许回归是的。
-
@Tunaki 是的,几分钟后我实际上意识到了这一点。我应该首先检查它的 JIRA 而不是 SO,我的错
-
@Tunaki 那我应该删除这个问题吗?
-
IMO 最好保留它,所以对于有相同问题的人来说,SO 可能是第一个去的地方。也可以作为欺骗目标。
-
好点,Google 在搜索时确实没有帮助我(Maven JIRA 的索引很可能不如 SO)。
标签: maven maven-3 pom.xml maven-compiler-plugin