我们正在忙于升级到Java 1.7。不幸的是,当这些事情发生时,大量的应用程序不能在1.7以下编译并中断(即使覆盖标志传递给1.7)。计划是尽快重新考虑这些因素。通过Maven构建具有不同JDK版本的JAR
我想以这种方式配置Maven,以便可以基于POM中的某些属性使用不同的JDK。我遵循http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html这封信,但无论我做什么,maven都会忽略POM中指定的java。
的POM具有如下条目:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<fork>true</fork>
<source>1.6</source>
<target>1.6</target>
<compiler-version>1.6</compiler-version>
<executable>/usr/lib/jvm/java-6-openjdk/bin/javac</executable>
<debug>true</debug>
<verbose>true</verbose>
</configuration>
</plugin>
...
此外,我没有得到任何来自“详细”标志输出 - 我觉得奇怪。也许上面完全被忽略了?
编辑:我知道它不工作,因为检查META-INF/MANIFEST.MF文件显示不正确的java版本。使用的版本与当前路径中的javac相对应。
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: jaco
Build-Jdk: 1.7.0_147-icedtea
Implementation-Title: xxx
Implementation-Vendor: xxx
Implementation-Version: 1.3.7
Specification-Title: xxx
Specification-Vendor: xxx
Specification-Version: 1.3.7
编辑:其他的东西是比较有趣的。如果我故意在破解文件参考,我得到:
[INFO] Compilation failure
Failure executing javac, but could not parse the error:
/bin/sh: /usr/lib/jvm/java-6-openjdk: Permission denied
编辑:我怀疑问题出在组件构建清单文件。如果我在我的机器上破坏了Java 7(即将javac重命名为javac.pleasegoaway),它会编译!但是,清单文件仍然报告1.7版。现在这已经过去了,变得闹得沸沸扬扬。
一些帮助将不胜感激,谢谢。
您是否对文档在链接中建议的settings.xml进行了更改? – aglassman
我做过了,但由于它不起作用,我硬编码路径以完全绕过它。 –
标签中是否有标签正确标记标签? –
aglassman