我的项目必须使用 JAVA 1.3 构建,因此我使用以下编译插件:
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<source>1.3</source>
<target>1.3</target>
</configuration>
</plugin>
。但是,在构建过程中,我需要执行 JUNIT4 测试,因此我需要 sunfire 插件才能使用 java 1.6。这在 Maven 3 中可能吗?
最佳答案
将您的插件配置更改为如下所示:
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.3</source>
<target>1.3</target>
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</execution>
</executions>
</plugin>
关于maven - 使用 Maven 3 是否可以使用与编译插件中设置不同的 java 版本来运行 JUNIT 测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13232274/