jeudi 9 mai 2013

Maven et Java 7 : Fatal error compiling: invalid target release: 1.7


 Problème

Sur un projet Maven, je suis passé de java 1.6 à java 1.7 dans mon pom.xml


[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project MetricViewer: Fatal error compiling: invalid target release: 1.7 -> [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/MojoExecutionException



Solution

 Vous utilisez probablement encore Java 6.
 Pour le vérifier, faites :

mvn clean install --debug

  1 Apache Maven 3.0.3 (r1075438; 2011-02-28 11:31:09-0600)
  2 Maven home: /usr/share/maven
  3 Java version: 1.6.0_35, vendor: Apple Inc.
  4 Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home



J'ai trouvé cette solution sur http://stackoverflow.com/questions/14043042/compiling-java-7-code-via-maven