Maven does not use Java 7

I want to pack the maven- (multi) module, the parent POM includes:

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>${maven.compiler.source}</source> <target>${maven.compiler.target}</target> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin> 

I am using Java 1.7, and the properties are set as follows:

 <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> <slf4j.version>1.6.1</slf4j.version> </properties> 

Maven version is 2.2.1:

 johannes@luna:~/workspace/treetank/bundles/treetank-core$ mvn -version Apache Maven 2.2.1 (rdebian-6) Java version: 1.7.0 Java home: /usr/lib/jvm/jdk1.7.0/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux" version: "3.0.0-14-generic" arch: "amd64" Family: "unix" 

I do not know why it does not use Java version 1.7. When I call mvn package I get an error (for example, using source 7 or higher to enable the diamond operator). Do you know why he is trying to use 1.6?

Effective POM:

  <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <executions> <execution> <id>default-testCompile</id> <phase>test-compile</phase> <goals> <goal>testCompile</goal> </goals> <configuration> <source>1.7</source> <target>1.7</target> <encoding>UTF-8</encoding> </configuration> </execution> <execution> <id>default-compile</id> <phase>compile</phase> <goals> <goal>compile</goal> </goals> <configuration> <source>1.7</source> <target>1.7</target> <encoding>UTF-8</encoding> </configuration> </execution> </executions> <configuration> <source>1.7</source> <target>1.7</target> <encoding>UTF-8</encoding> </configuration> </plugin> 
+49
java maven java-7 maven-2
Jan 05 2018-12-12T00:
source share
2 answers

This may not work in maven 2.2.1, but with Maven 3.0.4 just adding two properties to the pom properties allows Java 7 for me:

 <properties> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> </properties> 
+119
Mar 22 '13 at 17:03
source share
β€” -

Excellent explanation of jdk 1.7 compatibility issue with maven 2.2.1 provided by Mark Peters Maven "couldn't parse error message" (Java 7 + Maven 2)

+2
Apr 27 2018-12-12T00:
source share



All Articles