2014-06-25 70 views
0

我正在将我的Java 6代码升级到java 7.已将JAVA_HOME更新为指向OS X 10.9上的JDK 1.7。该代码尚未使用任何Java 7功能。源代码为1.7(或7)的Java Maven构建失败

当我运行构建“mvn clean install”时,构建中断时没有任何有用的错误消息。

构建成功与源= 1.6 &目标= 1.6 但是失败源= 1.7(或7)&目标= 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 
+0

'mvn --version'输出什么? –

+0

和输出使用'mvn -e' –

+0

对于初学者,'7'不是合法版本。将其更改为正确的'1.7'并重试。 – chrylis

回答

2

我猜使用JDK 1.7编译您的代码会产生警告,编译时不会使用1.6。既然你告诉编译器在遇到<compilerArgument>-Werror </compilerArgument>的警告时简单地退出,那正是它在做什么,这对Maven不是很友好。我猜Maven吞下了最初的警告,赞成显示javac进程意外退出的错误。

删除<compilerArgument>-Werror </compilerArgument>指令应该允许编译继续。你可能需要处理编译器警告,而不是仅仅通过编译器退出,这可能是通过查看/分析Maven输出来实现的。