Why do I need Java 1.5 for Maven2 project?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Why do I need Java 1.5 for Maven2 project?

Michael Meyer
Hi
we have a maven2 multi module build. Unfortunately we are stuck with an
ibm 1.4.2 jre.

When I try to build my project with hudson I get the following error
message: "Native maven support requires Java 1.5 or later, but this
Maven is using D:\local\jre_1.4.2\jre"

This is my setup:
- Started hudson with a sun jdk 6 installation
- Went to "Manage Hudson -> System Configuration" and added an entry for
my ibm 1.4.2 jre
- Went to "New Job -> Build a maven2 project (alpha)" where I added my
project and choose the jre that I added in the previous step

Hudson then checks out my project, finds all my modules (cool!) and
tries to build the first module. There I get the error message that I've
mentioned above.

So my question: Why do I need a java 1.5 jre both for Hudson and for my
maven2 build? Is this absolutely necessery?

Cheers, michael



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Why do I need Java 1.5 for Maven2 project?

Kohsuke Kawaguchi
Administrator
Michael Meyer wrote:
> So my question: Why do I need a java 1.5 jre both for Hudson and for my
> maven2 build? Is this absolutely necessery?

Much of the native m2 support is made possible by running probes inside
the Maven process. This is the code that monitors what's going on, and
record key information, such as where javadoc was generated, what jar
files are produced, etc. This probe code is written in Java5, and hence
this requirement.

In theory, it is possible to do all of this w/o using Java5. In fact, up
until certain versions of Hudson, Hudson was doing some pretty nasty
tricks so that we can write in Java5 but runs on Java1.4. We felt that
the pain of doing this is just too much to justify 1.4 support.

Note that it's perfectly feasible to develop applications for 1.4 by
using 1.5 JDK --- although you'd end up losing certain kind of error
checking and so on.

--
Kohsuke Kawaguchi
Sun Microsystems                   [hidden email]

smime.p7s (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Why do I need Java 1.5 for Maven2 project?

Stephen Connolly-2
In reply to this post by Michael Meyer
Michael,

Short answer, yes!

Long answer:

Hudson makes extensive use of generics.  Thus hudson has to be compiled with JDK 1.5.  There is no possibility of removing the generics from the code as it is too well integrated.

(An aside: to make things more fun, there is a bug in JDK 1.5 to do with generic exceptions, so Hudson needs to be compiled with JDK 1.6. Thankfully, this is just a compilation requirements and not a runtime requirement, so we can run Hudson with JDK 1.5)

Up until builds in the 1.90ish area, the Hudson build process would use retrotranslator to backport the Hudson to work on JDK 1.4.

However, retrotranslator is not perfect.  It does not catch every case where you have used a method that was introduced in JDK 1.5.  Very often, it would take a couple of days before somebody would catch the problem.

Basically, using retrotranslator was a patch over the seeping wound at best.  So retrotranslator was dropped, and you must run Hudson with JRE 1.5.

The Maven2 project type (alpha) uses Maven in a semi-embedded mode, therefore, it must run Maven in the same JRE (as far as I know).

However, there is a far better solution.

in your ~/.m2/settings.xml put a
  <properties>
    <jdk.ibm.1.4.2.path>c:\jdks\ibm-1.4.2\</jdk.ibm.1.4.2.path> 
    <jdk.ibm.1.4.2.javac>${jdk.ibm.1.4.2.path}bin\javac.exe</jdk.ibm.1.4.2.javac> 
    <jdk.ibm.1.4.2.javac>${jdk.ibm.1.4.2.path}bin\javac</jdk.ibm.1.4.2.javac> 
  </properties>

Then change your project's pom.xml such that you have something like

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <verbose>true</verbose>
          <fork>true</fork>
          <executable>${jdk.ibm.1.4.2.javac}</executable>
          <compilerVersion>1.4</compilerVersion>
        </configuration>
      </plugin>

That should let you use JDK 1.5 for your Maven, and compile with the IBM JDK.

There is similar functionality in the surefire plugin (use a forkmode of at least "once" or "always") to force the unit tests to run with the specified JDK

That should fix things for you!

-Stephen.
Michael Meyer-5 wrote
Hi
we have a maven2 multi module build. Unfortunately we are stuck with an
ibm 1.4.2 jre.

When I try to build my project with hudson I get the following error
message: "Native maven support requires Java 1.5 or later, but this
Maven is using D:\local\jre_1.4.2\jre"

This is my setup:
- Started hudson with a sun jdk 6 installation
- Went to "Manage Hudson -> System Configuration" and added an entry for
my ibm 1.4.2 jre
- Went to "New Job -> Build a maven2 project (alpha)" where I added my
project and choose the jre that I added in the previous step

Hudson then checks out my project, finds all my modules (cool!) and
tries to build the first module. There I get the error message that I've
mentioned above.

So my question: Why do I need a java 1.5 jre both for Hudson and for my
maven2 build? Is this absolutely necessery?

Cheers, michael



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@hudson.dev.java.net
For additional commands, e-mail: users-help@hudson.dev.java.net
Reply | Threaded
Open this post in threaded view
|

Re: Why do I need Java 1.5 for Maven2 project?

Stephen Connolly-2
In reply to this post by Kohsuke Kawaguchi

kohsuke wrote
Michael Meyer wrote:
> So my question: Why do I need a java 1.5 jre both for Hudson and for my
> maven2 build? Is this absolutely necessery?

Much of the native m2 support is made possible by running probes inside
the Maven process. This is the code that monitors what's going on, and
record key information, such as where javadoc was generated, what jar
files are produced, etc. This probe code is written in Java5, and hence
this requirement.

In theory, it is possible to do all of this w/o using Java5. In fact, up
until certain versions of Hudson, Hudson was doing some pretty nasty
tricks so that we can write in Java5 but runs on Java1.4. We felt that
the pain of doing this is just too much to justify 1.4 support.

Note that it's perfectly feasible to develop applications for 1.4 by
using 1.5 JDK --- although you'd end up losing certain kind of error
checking and so on.

--
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi@sun.com

 
Kohsuke,

See my (longer to type) reply for how to get Maven to compile with a specific JDK

-Stephen.
Reply | Threaded
Open this post in threaded view
|

Re: Why do I need Java 1.5 for Maven2 project?

Kohsuke Kawaguchi
Administrator
In reply to this post by Stephen Connolly-2

Cool.

Any chance you can put this on Wiki?

Stephen Connolly wrote:

> Michael,
>
> Short answer, yes!
>
> Long answer:
>
> Hudson makes extensive use of generics.  Thus hudson has to be compiled with
> JDK 1.5.  There is no possibility of removing the generics from the code as
> it is too well integrated.
>
> (An aside: to make things more fun, there is a bug in JDK 1.5 to do with
> generic exceptions, so Hudson needs to be compiled with JDK 1.6. Thankfully,
> this is just a compilation requirements and not a runtime requirement, so we
> can run Hudson with JDK 1.5)
>
> Up until builds in the 1.90ish area, the Hudson build process would use
> retrotranslator to backport the Hudson to work on JDK 1.4.
>
> However, retrotranslator is not perfect.  It does not catch every case where
> you have used a method that was introduced in JDK 1.5.  Very often, it would
> take a couple of days before somebody would catch the problem.
>
> Basically, using retrotranslator was a patch over the seeping wound at best.
> So retrotranslator was dropped, and you must run Hudson with JRE 1.5.
>
> The Maven2 project type (alpha) uses Maven in a semi-embedded mode,
> therefore, it must run Maven in the same JRE (as far as I know).
>
> However, there is a far better solution.
>
> in your ~/.m2/settings.xml put a
>   <properties>
>     <jdk.ibm.1.4.2.path>c:\jdks\ibm-1.4.2\</jdk.ibm.1.4.2.path> <!-- or
> whatever your local path is -->
>    
> <jdk.ibm.1.4.2.javac>${jdk.ibm.1.4.2.path}bin\javac.exe</jdk.ibm.1.4.2.javac>
> <!-- if windows -->
>    
> <jdk.ibm.1.4.2.javac>${jdk.ibm.1.4.2.path}bin\javac</jdk.ibm.1.4.2.javac>
> <!-- if *nix -->
>   </properties>
>
> Then change your project's pom.xml such that you have something like
>
>       <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-compiler-plugin</artifactId>
>         <configuration>
>           <verbose>true</verbose>
>           <fork>true</fork>
>           <executable>${jdk.ibm.1.4.2.javac}</executable>
>           <compilerVersion>1.4</compilerVersion>
>         </configuration>
>       </plugin>
>
> That should let you use JDK 1.5 for your Maven, and compile with the IBM
> JDK.
>
> There is similar functionality in the surefire plugin (use a forkmode of at
> least "once" or "always") to force the unit tests to run with the specified
> JDK
>
> That should fix things for you!
>
> -Stephen.
>
> Michael Meyer-5 wrote:
>>
>> Hi
>> we have a maven2 multi module build. Unfortunately we are stuck with an
>> ibm 1.4.2 jre.
>>
>> When I try to build my project with hudson I get the following error
>> message: "Native maven support requires Java 1.5 or later, but this
>> Maven is using D:\local\jre_1.4.2\jre"
>>
>> This is my setup:
>> - Started hudson with a sun jdk 6 installation
>> - Went to "Manage Hudson -> System Configuration" and added an entry for
>> my ibm 1.4.2 jre
>> - Went to "New Job -> Build a maven2 project (alpha)" where I added my
>> project and choose the jre that I added in the previous step
>>
>> Hudson then checks out my project, finds all my modules (cool!) and
>> tries to build the first module. There I get the error message that I've
>> mentioned above.
>>
>> So my question: Why do I need a java 1.5 jre both for Hudson and for my
>> maven2 build? Is this absolutely necessery?
>>
>> Cheers, michael
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>>
>

--
Kohsuke Kawaguchi
Sun Microsystems                   [hidden email]

smime.p7s (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Why do I need Java 1.5 for Maven2 project?

Michael Meyer
In reply to this post by Stephen Connolly-2
Hi Stephen,
thanks a lot. Will try that straight away :-)

Cheers, michael

Stephen Connolly wrote:

> Michael,
>
> Short answer, yes!
>
> Long answer:
>
> Hudson makes extensive use of generics.  Thus hudson has to be compiled with
> JDK 1.5.  There is no possibility of removing the generics from the code as
> it is too well integrated.
>
> (An aside: to make things more fun, there is a bug in JDK 1.5 to do with
> generic exceptions, so Hudson needs to be compiled with JDK 1.6. Thankfully,
> this is just a compilation requirements and not a runtime requirement, so we
> can run Hudson with JDK 1.5)
>
> Up until builds in the 1.90ish area, the Hudson build process would use
> retrotranslator to backport the Hudson to work on JDK 1.4.
>
> However, retrotranslator is not perfect.  It does not catch every case where
> you have used a method that was introduced in JDK 1.5.  Very often, it would
> take a couple of days before somebody would catch the problem.
>
> Basically, using retrotranslator was a patch over the seeping wound at best.
> So retrotranslator was dropped, and you must run Hudson with JRE 1.5.
>
> The Maven2 project type (alpha) uses Maven in a semi-embedded mode,
> therefore, it must run Maven in the same JRE (as far as I know).
>
> However, there is a far better solution.
>
> in your ~/.m2/settings.xml put a
>   <properties>
>     <jdk.ibm.1.4.2.path>c:\jdks\ibm-1.4.2\</jdk.ibm.1.4.2.path> <!-- or
> whatever your local path is -->
>    
> <jdk.ibm.1.4.2.javac>${jdk.ibm.1.4.2.path}bin\javac.exe</jdk.ibm.1.4.2.javac>
> <!-- if windows -->
>    
> <jdk.ibm.1.4.2.javac>${jdk.ibm.1.4.2.path}bin\javac</jdk.ibm.1.4.2.javac>
> <!-- if *nix -->
>   </properties>
>
> Then change your project's pom.xml such that you have something like
>
>       <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-compiler-plugin</artifactId>
>         <configuration>
>           <verbose>true</verbose>
>           <fork>true</fork>
>           <executable>${jdk.ibm.1.4.2.javac}</executable>
>           <compilerVersion>1.4</compilerVersion>
>         </configuration>
>       </plugin>
>
> That should let you use JDK 1.5 for your Maven, and compile with the IBM
> JDK.
>
> There is similar functionality in the surefire plugin (use a forkmode of at
> least "once" or "always") to force the unit tests to run with the specified
> JDK
>
> That should fix things for you!
>
> -Stephen.
>
> Michael Meyer-5 wrote:
>> Hi
>> we have a maven2 multi module build. Unfortunately we are stuck with an
>> ibm 1.4.2 jre.
>>
>> When I try to build my project with hudson I get the following error
>> message: "Native maven support requires Java 1.5 or later, but this
>> Maven is using D:\local\jre_1.4.2\jre"
>>
>> This is my setup:
>> - Started hudson with a sun jdk 6 installation
>> - Went to "Manage Hudson -> System Configuration" and added an entry for
>> my ibm 1.4.2 jre
>> - Went to "New Job -> Build a maven2 project (alpha)" where I added my
>> project and choose the jre that I added in the previous step
>>
>> Hudson then checks out my project, finds all my modules (cool!) and
>> tries to build the first module. There I get the error message that I've
>> mentioned above.
>>
>> So my question: Why do I need a java 1.5 jre both for Hudson and for my
>> maven2 build? Is this absolutely necessery?
>>
>> Cheers, michael
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>>
>

--
Michael Meyer | [hidden email]
phone +41-44-247 79 12 | fax +41-44-247 70 75
Netcetera AG | 8040 Z├╝rich | Switzerland | http://netcetera.ch

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Why do I need Java 1.5 for Maven2 project?

Stephen Connolly-2
In reply to this post by Kohsuke Kawaguchi
kohsuke wrote
Any chance you can put this on Wiki?
I'm kind of busy at the moment, and it would require me to use them "Maven2 project (alpha)" style projects on Hudson just to confirm that my instructions work. (And since "Maven2 project (alpha)" style projects fundamentally don't work with aggregator goals and I need an aggregated clover coverage report for all my projects that won't be happening just now)

But I've no problems with Michael putting it up on the Wiki when he's confirmed that it works for him.

-Stephen.

Reply | Threaded
Open this post in threaded view
|

Re: Why do I need Java 1.5 for Maven2 project?

Kohsuke Kawaguchi
Administrator
Stephen Connolly wrote:

>
> kohsuke wrote:
>>
>> Any chance you can put this on Wiki?
>>
>
> I'm kind of busy at the moment, and it would require me to use them "Maven2
> project (alpha)" style projects on Hudson just to confirm that my
> instructions work. (And since "Maven2 project (alpha)" style projects
> fundamentally don't work with aggregator goals and I need an aggregated
> clover coverage report for all my projects that won't be happening just now)
>
> But I've no problems with Michael putting it up on the Wiki when he's
> confirmed that it works for him.
OK. I put it
http://hudson.gotdns.com/wiki/display/HUDSON/Maven2+project+and+JDK5

--
Kohsuke Kawaguchi
Sun Microsystems                   [hidden email]

smime.p7s (4K) Download Attachment