You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Olivier Serve <ol...@bull.net> on 2008/01/16 17:33:25 UTC

Use 1.6 JRE globally

Hi _o/

I have a little project that requires a JDK 1.6 (it uses some 1.6 specific APIs).
I have both Java 1.5 and 1.6 installed on my system to do some tests.

Using the following, I can build the artifact.
------------------------------8<------------------------------
<project>
  ...
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <compilerVersion>1.6</compilerVersion>
          <fork>true</fork>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
</project>
------------------------------8<------------------------------

However, the tests fail to execute with a "Bad version number in .class file".
OK, the surefire plugin must be using the 1.5 JRE to execute the tests and thus fails.
There must be a way to tell it to use a 1.6 JRE and that would solve my problem.

But I find it quite a bad precatice to have to state in two locations that I need a 1.6 jre.
Is there a way to tell maven to use a JRE 1.6 for all Java-related things in a single location ?
-- 
Cordialement,
Olivier SERVE

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


Re: Use 1.6 JRE globally

Posted by Olivier Serve <ol...@bull.net>.
Le mercredi 16 janvier 2008, Ian Springer a écrit :
> 
> >> set JAVA_HOME JRE_HOME correctly
> >>     
> >
> > No, because doing this will make the build non-reproducible on other environments as I will lose the 1.6 requirement.
> >   
> 
> You can use the enforcer plugin in your pom to specify that your project 
> requires Java 1.6. See 
> http://maven.apache.org/plugins/maven-enforcer-plugin/usage.html.

Yes, I've seen that.
Thanks for having confirmed.
-- 
Cordialement,
Olivier SERVE

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


Re: Use 1.6 JRE globally

Posted by Ian Springer <ia...@redhat.com>.
>> set JAVA_HOME JRE_HOME correctly
>>     
>
> No, because doing this will make the build non-reproducible on other environments as I will lose the 1.6 requirement.
>   

You can use the enforcer plugin in your pom to specify that your project 
requires Java 1.6. See 
http://maven.apache.org/plugins/maven-enforcer-plugin/usage.html.


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


Re: Use 1.6 JRE globally

Posted by Olivier Serve <ol...@bull.net>.
Le mercredi 16 janvier 2008, Hayes, Peter a écrit :
> You may want to look at using the enforcer plugin :
> 
> http://maven.apache.org/plugins/maven-enforcer-plugin/
> 
> This would allow you to guarantee that the jdk running is the build's required JDK.
>
> As to your initial question, I agree that the only way to set the JDK versino globally in Maven is to execute Maven with the JDK home set to the VM you require.  Otherwise you are going to have to configure individual plugins (like surefire) to point to the path of the VM that you require.  This is not portable and should be avoided.

Thank you, solved \o/

> 
> Pete 
> 
> -----Original Message-----
> From: Michael [mailto:sgfan@gmx.net] 
> Sent: Wednesday, January 16, 2008 11:51 AM
> To: Maven Users List
> Subject: Re: Use 1.6 JRE globally
> 
> Olivier Serve wrote:
> > Le mercredi 16 janvier 2008, Michael a écrit :
> >> Olivier Serve wrote:
> >>> Hi _o/
> >>>
> >>> I have a little project that requires a JDK 1.6 (it uses some 1.6 specific APIs).
> >>> I have both Java 1.5 and 1.6 installed on my system to do some tests.
> >>>
> >>> Using the following, I can build the artifact.
> >>> ------------------------------8<------------------------------
> >>> <project>
> >>>   ...
> >>>   <build>
> >>>     <plugins>
> >>>       <plugin>
> >>>         <artifactId>maven-compiler-plugin</artifactId>
> >>>         <configuration>
> >>>           <compilerVersion>1.6</compilerVersion>
> >>>           <fork>true</fork>
> >>>           <source>1.6</source>
> >>>           <target>1.6</target>
> >>>         </configuration>
> >>>       </plugin>
> >>>     </plugins>
> >>>   </build>
> >>>   ...
> >>> </project>
> >>> ------------------------------8<------------------------------
> >>>
> >>> However, the tests fail to execute with a "Bad version number in .class file".
> >>> OK, the surefire plugin must be using the 1.5 JRE to execute the tests and thus fails.
> >>> There must be a way to tell it to use a 1.6 JRE and that would solve my problem.
> >>>
> >>> But I find it quite a bad precatice to have to state in two locations that I need a 1.6 jre.
> >>> Is there a way to tell maven to use a JRE 1.6 for all Java-related things in a single location ?
> >> set JAVA_HOME JRE_HOME correctly
> > 
> > No, because doing this will make the build non-reproducible on other environments as I will lose the 1.6 requirement.
> 
> you could set i temporary for the each maven instance
> 



-- 
Cordialement,

Olivier SERVE
Ingénieur en développement de solutions de sécurité
Bull, Architect of an Open World TM
Tél : 02 41 93 55 16
http://www.bull.com

Ce message contient des informations confidentielles, couvertes par le
secret professionnel ou réservées exclusivement à leur destinataire. Toute
lecture, utilisation, diffusion ou divulgation sans autorisation expresse
est rigoureusement interdite.
Si vous n'en êtes pas le destinataire, merci de prendre contact avec
l'expéditeur et de détruire ce message.

This e-mail contains material that is confidential for the sole use of the
intended recipient. Any review, reliance or distribution by others or
forwarding without express permission is strictly prohibited.
If you are not the intended recipient, please contact the sender and delete
all copies.

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


RE: Use 1.6 JRE globally

Posted by "Hayes, Peter" <Pe...@fmr.com>.
You may want to look at using the enforcer plugin :

http://maven.apache.org/plugins/maven-enforcer-plugin/

This would allow you to guarantee that the jdk running is the build's required JDK.  

As to your initial question, I agree that the only way to set the JDK versino globally in Maven is to execute Maven with the JDK home set to the VM you require.  Otherwise you are going to have to configure individual plugins (like surefire) to point to the path of the VM that you require.  This is not portable and should be avoided.

Pete 

-----Original Message-----
From: Michael [mailto:sgfan@gmx.net] 
Sent: Wednesday, January 16, 2008 11:51 AM
To: Maven Users List
Subject: Re: Use 1.6 JRE globally

Olivier Serve wrote:
> Le mercredi 16 janvier 2008, Michael a écrit :
>> Olivier Serve wrote:
>>> Hi _o/
>>>
>>> I have a little project that requires a JDK 1.6 (it uses some 1.6 specific APIs).
>>> I have both Java 1.5 and 1.6 installed on my system to do some tests.
>>>
>>> Using the following, I can build the artifact.
>>> ------------------------------8<------------------------------
>>> <project>
>>>   ...
>>>   <build>
>>>     <plugins>
>>>       <plugin>
>>>         <artifactId>maven-compiler-plugin</artifactId>
>>>         <configuration>
>>>           <compilerVersion>1.6</compilerVersion>
>>>           <fork>true</fork>
>>>           <source>1.6</source>
>>>           <target>1.6</target>
>>>         </configuration>
>>>       </plugin>
>>>     </plugins>
>>>   </build>
>>>   ...
>>> </project>
>>> ------------------------------8<------------------------------
>>>
>>> However, the tests fail to execute with a "Bad version number in .class file".
>>> OK, the surefire plugin must be using the 1.5 JRE to execute the tests and thus fails.
>>> There must be a way to tell it to use a 1.6 JRE and that would solve my problem.
>>>
>>> But I find it quite a bad precatice to have to state in two locations that I need a 1.6 jre.
>>> Is there a way to tell maven to use a JRE 1.6 for all Java-related things in a single location ?
>> set JAVA_HOME JRE_HOME correctly
> 
> No, because doing this will make the build non-reproducible on other environments as I will lose the 1.6 requirement.

you could set i temporary for the each maven instance

-- 
<NO> OOXML - Say NO To Microsoft Office broken standard
http://www.noooxml.org


---------------------------------------------------------------------
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: Use 1.6 JRE globally

Posted by Michael <sg...@gmx.net>.
Olivier Serve wrote:
> Le mercredi 16 janvier 2008, Michael a écrit :
>> Olivier Serve wrote:
>>> Hi _o/
>>>
>>> I have a little project that requires a JDK 1.6 (it uses some 1.6 specific APIs).
>>> I have both Java 1.5 and 1.6 installed on my system to do some tests.
>>>
>>> Using the following, I can build the artifact.
>>> ------------------------------8<------------------------------
>>> <project>
>>>   ...
>>>   <build>
>>>     <plugins>
>>>       <plugin>
>>>         <artifactId>maven-compiler-plugin</artifactId>
>>>         <configuration>
>>>           <compilerVersion>1.6</compilerVersion>
>>>           <fork>true</fork>
>>>           <source>1.6</source>
>>>           <target>1.6</target>
>>>         </configuration>
>>>       </plugin>
>>>     </plugins>
>>>   </build>
>>>   ...
>>> </project>
>>> ------------------------------8<------------------------------
>>>
>>> However, the tests fail to execute with a "Bad version number in .class file".
>>> OK, the surefire plugin must be using the 1.5 JRE to execute the tests and thus fails.
>>> There must be a way to tell it to use a 1.6 JRE and that would solve my problem.
>>>
>>> But I find it quite a bad precatice to have to state in two locations that I need a 1.6 jre.
>>> Is there a way to tell maven to use a JRE 1.6 for all Java-related things in a single location ?
>> set JAVA_HOME JRE_HOME correctly
> 
> No, because doing this will make the build non-reproducible on other environments as I will lose the 1.6 requirement.

you could set i temporary for the each maven instance

-- 
<NO> OOXML - Say NO To Microsoft Office broken standard
http://www.noooxml.org


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


Re: Use 1.6 JRE globally

Posted by Olivier Serve <ol...@bull.net>.
Le mercredi 16 janvier 2008, Michael a écrit :
> Olivier Serve wrote:
> > Hi _o/
> > 
> > I have a little project that requires a JDK 1.6 (it uses some 1.6 specific APIs).
> > I have both Java 1.5 and 1.6 installed on my system to do some tests.
> > 
> > Using the following, I can build the artifact.
> > ------------------------------8<------------------------------
> > <project>
> >   ...
> >   <build>
> >     <plugins>
> >       <plugin>
> >         <artifactId>maven-compiler-plugin</artifactId>
> >         <configuration>
> >           <compilerVersion>1.6</compilerVersion>
> >           <fork>true</fork>
> >           <source>1.6</source>
> >           <target>1.6</target>
> >         </configuration>
> >       </plugin>
> >     </plugins>
> >   </build>
> >   ...
> > </project>
> > ------------------------------8<------------------------------
> > 
> > However, the tests fail to execute with a "Bad version number in .class file".
> > OK, the surefire plugin must be using the 1.5 JRE to execute the tests and thus fails.
> > There must be a way to tell it to use a 1.6 JRE and that would solve my problem.
> > 
> > But I find it quite a bad precatice to have to state in two locations that I need a 1.6 jre.
> > Is there a way to tell maven to use a JRE 1.6 for all Java-related things in a single location ?
> 
> set JAVA_HOME JRE_HOME correctly

No, because doing this will make the build non-reproducible on other environments as I will lose the 1.6 requirement.
-- 
Cordialement,
Olivier SERVE

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


Re: Use 1.6 JRE globally

Posted by Michael <sg...@gmx.net>.
Olivier Serve wrote:
> Hi _o/
> 
> I have a little project that requires a JDK 1.6 (it uses some 1.6 specific APIs).
> I have both Java 1.5 and 1.6 installed on my system to do some tests.
> 
> Using the following, I can build the artifact.
> ------------------------------8<------------------------------
> <project>
>   ...
>   <build>
>     <plugins>
>       <plugin>
>         <artifactId>maven-compiler-plugin</artifactId>
>         <configuration>
>           <compilerVersion>1.6</compilerVersion>
>           <fork>true</fork>
>           <source>1.6</source>
>           <target>1.6</target>
>         </configuration>
>       </plugin>
>     </plugins>
>   </build>
>   ...
> </project>
> ------------------------------8<------------------------------
> 
> However, the tests fail to execute with a "Bad version number in .class file".
> OK, the surefire plugin must be using the 1.5 JRE to execute the tests and thus fails.
> There must be a way to tell it to use a 1.6 JRE and that would solve my problem.
> 
> But I find it quite a bad precatice to have to state in two locations that I need a 1.6 jre.
> Is there a way to tell maven to use a JRE 1.6 for all Java-related things in a single location ?

set JAVA_HOME JRE_HOME correctly

-- 
<NO> OOXML - Say NO To Microsoft Office broken standard
http://www.noooxml.org

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