0
votes

I am upgrading my java 6 code to java 7. Have updated JAVA_HOME to point to JDK 1.7 on OS X 10.9. The code is not using any Java 7 features yet.

When I run the build "mvn clean install" the build breaks without any helpful error message.

The build succeeds with source=1.6 & target=1.6 But fails for source=1.7 (or 7) & target=1.7 (or 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
1
what does mvn --version outputs ?jmj
and also the output using mvn -eAlvin Thompson
For starters, 7 isn't a legal version. Change it to the correct 1.7 and try again.chrylis -cautiouslyoptimistic-

1 Answers

2
votes

I'm guessing that compiling your code with JDK 1.7 produces warnings that compiling with 1.6 did not. Since you're telling the compiler to simply quit when it encounters a warning with <compilerArgument>-Werror </compilerArgument>, that's exactly what it's doing, which isn't very Maven-friendly. I'm guessing Maven swallows the original warning in favor of showing the error of the javac process quitting unexpectedly.

Removing the <compilerArgument>-Werror </compilerArgument> directive should allow compilation to continue. You'll have to deal with the compiler warnings a better way than by just having the compiler quit, perhaps by looking at/parsing the Maven output.