我正在使用 Maven 3.2.3。我有一个多模块项目,目前我的 Maven 编译器插件设置为这样
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-proc:none</compilerArgument>
<fork>true</fork>
<!-- <debug>true</debug> <debuglevel>none</debuglevel> -->
</configuration>
<executions>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
我想知道如何根据系统中的 $JAVA_HOME 变量设置编译器版本,这意味着,如果 $JAVA_HOME 指向 Java 6 安装,我的 Maven 编译器将使用“1.6”作为其源和目标。同样,如果我的 $JAVA_HOME 指向 Java 7 安装,则源和目标将是“1.7”,依此类推。如果环境中没有设置 $JAVA_HOME,我希望编译器默认为 1.6。
感谢您提供有关如何设置的建议和示例。