我目前正在开发一个将在嵌入式设备上运行的项目。该设备运行 Java ME JRE(相当于 Java 1.4)。
因此,maven 配置为针对源级别和目标级别 1.4 进行编译。
是否可以在不同的源/目标级别上运行 Maven 测试阶段?因为这样我就可以使用 Mockito 进行单元测试。
可以分别设置源版本和目标版本compile http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#source and 测试编译 http://maven.apache.org/plugins/maven-compiler-plugin/testCompile-mojo.html#testSource的目标maven编译器插件 http://maven.apache.org/plugins/maven-compiler-plugin/。您可以通过在 pom 中定义属性来更改设置:
<properties>
<maven.compiler.source>1.4</maven.compiler.source>
<maven.compiler.target>1.4</maven.compiler.target>
<maven.compiler.testSource>1.5</maven.compiler.testSource>
<maven.compiler.testTarget>1.5</maven.compiler.testTarget>
</properties>
或者通过编译器插件的显式配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.4</version>
<configuration>
<source>1.4</source>
<target>1.4</target>
<testSource>1.5</testSource>
<testTarget>1.5</testTarget>
</configuration>
</plugin>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)