You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Johannes.Lichtenberger" <Jo...@uni-konstanz.de> on 2012/01/05 23:24:09 UTC

Maven / Java 1.7 compliance

Hello,

I want to package a 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'm using Java 1.7 and the properties are specified 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>
The 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 have no clue why it doesn't use java version 1.7. When invoking mvn
package I get the error (use -source 7 or higher to enable diamond
operator) for instance. Do you know why it tries using 1.6?

kind regards,
Johannes

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven / Java 1.7 compliance

Posted by rahulmishramail <ra...@wipro.com>.
Hi Johannes

For a long time, i was facing the same issue. But i finally got the
solution.
If you are using maven version 3.0.4 or above, then certainly your code will
compile in 1.7. Just add the below two properties in the <properties>
section of your project Pom file.

<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>

The code will compile fine in 1.7. Please see the below link for further
info.
http://stackoverflow.com/questions/8750563/maven-doesnt-use-java-7

P.S : If you are using maven version prior to 3.0.4 version, than there will
be a compilation issue. So, better you update your maven version.


Regards
Rahul
Contact : +91-9540488347



--
View this message in context: http://maven.40175.n5.nabble.com/Maven-Java-1-7-compliance-tp5124043p5781227.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven / Java 1.7 compliance

Posted by Guillaume Polet <gu...@gmail.com>.
He is running 1.7, since he gets an explicit message from the compiler 
to use source "7" and he already posted the output of the mvn --version.
Have you tried the debug mode with -X to see what the maven compiler 
does? Have you tried directly setting the properties to "1.7" in the 
configuration instead of using properties (just for testing)? Also, you 
could try dropping the configuration part (except the encoding) since 
you are using the maven properties corresponding to that configuration.

Cheers,
Guillaume
Le 6/01/2012 09:52, Holger Hoffstaette a écrit :
> On Fri, 06 Jan 2012 03:45:19 +0100, Johannes.Lichtenberger wrote:
>
>> On 01/06/2012 02:54 AM, Dave Wolf wrote:
>>> Instead of "1.7" try simply "7".
>> Seems it doesn't have any impact. In Eclipse itself it doesn't seem to
>> change anything, too, but in Eclipse the build path is correct for all
>> projects. I just want to get `mvn` in the shell running after I've updated
>> the projects to Java 7 some time ago to double check if the unit tests are
>> working before commiting to the CI-Server (and to produce JARs).
> I can compile JDK7 source just fine (using new 7-only classes etc., with
> "1.7" as source/target:
>
> ..
> <plugin>
>      <groupId>org.apache.maven.plugins</groupId>
>      <artifactId>maven-compiler-plugin</artifactId>
>      <version>${compiler.plugin.version}</version>
>      <configuration>
>          <source>1.7</source>
>          <target>1.7</target>
>      </configuration>
> </plugin>
> ..
>
> maven-compiler-plugin is 2.3.2.
>
> Try mvn --version to verify that you are really using the correct JDK.
>
> -h
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven / Java 1.7 compliance

Posted by Holger Hoffstaette <ho...@googlemail.com>.
On Fri, 06 Jan 2012 03:45:19 +0100, Johannes.Lichtenberger wrote:

> On 01/06/2012 02:54 AM, Dave Wolf wrote:
>> Instead of "1.7" try simply "7".
> 
> Seems it doesn't have any impact. In Eclipse itself it doesn't seem to
> change anything, too, but in Eclipse the build path is correct for all
> projects. I just want to get `mvn` in the shell running after I've updated
> the projects to Java 7 some time ago to double check if the unit tests are
> working before commiting to the CI-Server (and to produce JARs).

I can compile JDK7 source just fine (using new 7-only classes etc., with
"1.7" as source/target:

..
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>${compiler.plugin.version}</version>
    <configuration>
        <source>1.7</source>
        <target>1.7</target>
    </configuration>
</plugin>
..

maven-compiler-plugin is 2.3.2.

Try mvn --version to verify that you are really using the correct JDK.

-h



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven / Java 1.7 compliance

Posted by "Johannes.Lichtenberger" <Jo...@uni-konstanz.de>.
On 01/06/2012 02:54 AM, Dave Wolf wrote:
> Instead of "1.7" try simply "7".

Seems it doesn't have any impact. In Eclipse itself it doesn't seem to
change anything, too, but in Eclipse the build path is correct for all
projects. I just want to get `mvn` in the shell running after I've
updated the projects to Java 7 some time ago to double check if the unit
tests are working before commiting to the CI-Server (and to produce JARs).

kind regards,
Johannes


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: Maven / Java 1.7 compliance

Posted by Dave Wolf <dw...@digitalglobe.com>.
Instead of "1.7" try simply "7".

Dave Wolf 
Java Architect
Gorilla Logic



-----Original Message-----
From: Johannes.Lichtenberger [mailto:Johannes.Lichtenberger@uni-konstanz.de]
Sent: Thu 1/5/2012 4:00 PM
To: Maven Users List
Subject: Re: Maven / Java 1.7 compliance
 
On 01/05/2012 11:24 PM, Johannes.Lichtenberger wrote:
> Hello,
> 
> I want to package a 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'm using Java 1.7 and the properties are specified 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>
> The 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 have no clue why it doesn't use java version 1.7. When invoking mvn
> package I get the error (use -source 7 or higher to enable diamond
> operator) for instance. Do you know why it tries using 1.6?

The effective POM is:

      <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>

really strange :(


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org



This electronic communication and any attachments may contain confidential and proprietary 
information of DigitalGlobe, Inc. If you are not the intended recipient, or an agent or employee 
responsible for delivering this communication to the intended recipient, or if you have received 
this communication in error, please do not print, copy, retransmit, disseminate or 
otherwise use the information. Please indicate to the sender that you have received this 
communication in error, and delete the copy you received. DigitalGlobe reserves the 
right to monitor any electronic communication sent or received by its employees, agents 
or representatives.


Re: Maven / Java 1.7 compliance

Posted by "Johannes.Lichtenberger" <Jo...@uni-konstanz.de>.
On 01/05/2012 11:24 PM, Johannes.Lichtenberger wrote:
> Hello,
> 
> I want to package a 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'm using Java 1.7 and the properties are specified 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>
> The 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 have no clue why it doesn't use java version 1.7. When invoking mvn
> package I get the error (use -source 7 or higher to enable diamond
> operator) for instance. Do you know why it tries using 1.6?

The effective POM is:

      <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>

really strange :(


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org