我正在将我的java 6代码升级到java 7,更新后的JAVA_HOME指向OSX10.9上的JDK1.7。代码还没有使用任何Java 7特性。
当我运行构建"mvn干净安装“时,生成中断,没有任何有用的错误消息。
构建通过source=1.6和target=1.6继承了,但是对于source=1.7 (或7)和target=1.7 (或7),失败了
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version> <!-- tried with 2.3.2 and 3.0... no luck -->
<configuration>
<source>7</source>
<target>7</target>
<compilerArgument>-Werror </compilerArgument>
<fork>true</fork>
</configuration>
Error Message:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.773 s
[INFO] Finished at: 2014-06-25T14:56:13-08:00
[INFO] Final Memory: 10M/245M
[INFO] ------------------------------------------------------------------------
[**ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (default-testCompile) on project core: Compilation failure
[ERROR] Failure executing javac, but could not parse the error:
[ERROR] 1 error
[ERROR] -> [Help 1]**
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException发布于 2014-06-25 22:58:13
我猜用JDK1.7编译您的代码会产生警告,而用1.6编译则不会。由于您告诉编译器在遇到<compilerArgument>-Werror </compilerArgument>警告时直接退出,这正是它所要做的,这并不是非常友好的Maven。我猜Maven会吞下原来的警告,以显示javac进程意外退出的错误。
删除<compilerArgument>-Werror </compilerArgument>指令应该允许继续编译。您必须更好地处理编译器警告,而不是让编译器退出,比如查看/解析Maven输出。
https://stackoverflow.com/questions/24419402
复制相似问题