You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sebb <se...@gmail.com> on 2010/03/09 02:10:52 UTC

[ALL] Compile and Test under different JVM from Maven

I've done some investigations.

Maven can happily compile code with Java 1.3 or 1.4 etc. even when
Maven itself runs under Java 1.5+ [1]

This can be done by adding the following to the component POM:

<build>
   <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <fork>true</fork>
          <executable>${JAVA_1_3_HOME}/bin/javac</executable>
          <compilerVersion>${maven.compile.source}</compilerVersion>
        </configuration>

The variable JAVA_1_3_HOME can either be defined as:
+ an environment variable
+ added to settings.xml or
+ defined on the command line
(the above are processed in order, the last one takes precedence)

SureFire also allows a different JVM to be used:

<artifactId>maven-surefire-plugin</artifactId>
  <configuration>
     <jvm>${JAVA_1_4_HOME}/bin/java</jvm>

However, the current version of Surefire (2.4.3) does not run under
1.3.1; the latest version that seems to support 1.3 is Surefire 2.2,
so the parent version needs to be overridden with that in the
component pom.

So projects requiring Java 1.3 or 1.4 can be compiled and tested under Java 1.5+

But how best to implement this?

It's important that the POMS still work even if local system only has
(say) Java 1.5, but it would be nice if Maven automatically chose the
appropriate compiler if it is available (according to the environment
variables).

It would be neat if this could be implemented in the parent pom, but I
don't know enough about profiles to know if this is possible. Can the
parent pom refer to variables defined in a child pom?

What would be ideal is to activate the settings when the component
profile specifies compiler.source which is different from the JVM
which is running Maven.  If the appropriate environment variable
exists (i.e. the compiler exists) then process the settings, otherwise
report a warning and continue.

Otherwise, if the overrides can at least be enabled by setting a
command-line parameter, that would be OK.

1] http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [ALL] Compile and Test under different JVM from Maven

Posted by Niall Pemberton <ni...@gmail.com>.
On Thu, Mar 11, 2010 at 1:13 AM, Jörg Schaible <jo...@gmx.de> wrote:
> Hi Sebb,
>
> sebb wrote:
>
>> On 09/03/2010, Jörg Schaible <jo...@gmx.de> wrote:
>
> [snip]
>
>>> Another solution should be the animal sniffer:
>>>  http://mojo.codehaus.org/animal-sniffer-maven-plugin/
>>>
>>>  This should ensures that the generated byte code is using only the API
>>>  of a previously generated signature. There are already signatures for
>>>  the different JREs. This way you could even check for JRE 1.3
>>>  compatibility.
>>>
>>
>> Animal looks like a lot of work; and you have to create signatures for
>> each release (why are these not included as part of the plugin?)
>
> They are available as separate artifacts - at least for the JDK's:
> http://marc.info/?l=ant-user&m=125875633827232&w=2
> http://repo1.maven.org/maven2/org/codehaus/mojo/signature/
>
>> Using a profile looks to be fairly simple in comparison.
>
> Because you cannot cover JDK 1.3, you cannot cover JDK 1.4 when using Maven
> 2.2 or higher and everybody has to setup the parameters for the JDKs
> individually on his own.

Using the actual JDK though has to be *safer* than relying on animal
sniffer to pick up api creep and it doesn't allow you to test under
each JDK version. Setting up settings.xml is just a one off and its
optional for people who want to test on alternative versions. I like
it.

Niall

> - Jörg

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [ALL] Compile and Test under different JVM from Maven

Posted by Jörg Schaible <jo...@gmx.de>.
Hi Sebb,

sebb wrote:

> On 09/03/2010, Jörg Schaible <jo...@gmx.de> wrote:

[snip]

>> Another solution should be the animal sniffer:
>>  http://mojo.codehaus.org/animal-sniffer-maven-plugin/
>>
>>  This should ensures that the generated byte code is using only the API
>>  of a previously generated signature. There are already signatures for
>>  the different JREs. This way you could even check for JRE 1.3
>>  compatibility.
>>
> 
> Animal looks like a lot of work; and you have to create signatures for
> each release (why are these not included as part of the plugin?)

They are available as separate artifacts - at least for the JDK's:
http://marc.info/?l=ant-user&m=125875633827232&w=2
http://repo1.maven.org/maven2/org/codehaus/mojo/signature/

> Using a profile looks to be fairly simple in comparison.

Because you cannot cover JDK 1.3, you cannot cover JDK 1.4 when using Maven 
2.2 or higher and everybody has to setup the parameters for the JDKs 
individually on his own.

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [ALL] Compile and Test under different JVM from Maven

Posted by sebb <se...@gmail.com>.
On 09/03/2010, Jörg Schaible <jo...@gmx.de> wrote:
> sebb wrote at Dienstag, 9. März 2010 02:10:
>
>
>  > I've done some investigations.
>  >
>  > Maven can happily compile code with Java 1.3 or 1.4 etc. even when
>  > Maven itself runs under Java 1.5+ [1]
>  >
>  > This can be done by adding the following to the component POM:
>  >
>  > <build>
>  >    <plugins>
>  >       <plugin>
>  >         <groupId>org.apache.maven.plugins</groupId>
>  >         <artifactId>maven-compiler-plugin</artifactId>
>  >         <configuration>
>  >           <fork>true</fork>
>  >           <executable>${JAVA_1_3_HOME}/bin/javac</executable>
>  >           <compilerVersion>${maven.compile.source}</compilerVersion>
>  >         </configuration>
>  >
>  > The variable JAVA_1_3_HOME can either be defined as:
>  > + an environment variable
>  > + added to settings.xml or
>  > + defined on the command line
>  > (the above are processed in order, the last one takes precedence)
>  >
>  > SureFire also allows a different JVM to be used:
>  >
>  > <artifactId>maven-surefire-plugin</artifactId>
>  >   <configuration>
>  >      <jvm>${JAVA_1_4_HOME}/bin/java</jvm>
>  >
>  > However, the current version of Surefire (2.4.3) does not run under
>  > 1.3.1; the latest version that seems to support 1.3 is Surefire 2.2,
>  > so the parent version needs to be overridden with that in the
>  > component pom.
>  >
>  > So projects requiring Java 1.3 or 1.4 can be compiled and tested under
>  > Java 1.5+
>  >
>  > But how best to implement this?
>  >
>  > It's important that the POMS still work even if local system only has
>  > (say) Java 1.5, but it would be nice if Maven automatically chose the
>  > appropriate compiler if it is available (according to the environment
>  > variables).
>  >
>  > It would be neat if this could be implemented in the parent pom, but I
>  > don't know enough about profiles to know if this is possible. Can the
>  > parent pom refer to variables defined in a child pom?
>  >
>  > What would be ideal is to activate the settings when the component
>  > profile specifies compiler.source which is different from the JVM
>  > which is running Maven.  If the appropriate environment variable
>  > exists (i.e. the compiler exists) then process the settings, otherwise
>  > report a warning and continue.
>  >
>  > Otherwise, if the overrides can at least be enabled by setting a
>  > command-line parameter, that would be OK.
>  >
>  > 1]
>  > http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-
>  using-different-jdk.html
>
>
> Another solution should be the animal sniffer:
>  http://mojo.codehaus.org/animal-sniffer-maven-plugin/
>
>  This should ensures that the generated byte code is using only the API of a
>  previously generated signature. There are already signatures for the
>  different JREs. This way you could even check for JRE 1.3 compatibility.
>

Animal looks like a lot of work; and you have to create signatures for
each release (why are these not included as part of the plugin?)

Using a profile looks to be fairly simple in comparison.

>  - Jörg
>
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>  For additional commands, e-mail: dev-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [ALL] Compile and Test under different JVM from Maven

Posted by Jörg Schaible <jo...@gmx.de>.
sebb wrote at Dienstag, 9. März 2010 02:10:

> I've done some investigations.
> 
> Maven can happily compile code with Java 1.3 or 1.4 etc. even when
> Maven itself runs under Java 1.5+ [1]
> 
> This can be done by adding the following to the component POM:
> 
> <build>
>    <plugins>
>       <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-compiler-plugin</artifactId>
>         <configuration>
>           <fork>true</fork>
>           <executable>${JAVA_1_3_HOME}/bin/javac</executable>
>           <compilerVersion>${maven.compile.source}</compilerVersion>
>         </configuration>
> 
> The variable JAVA_1_3_HOME can either be defined as:
> + an environment variable
> + added to settings.xml or
> + defined on the command line
> (the above are processed in order, the last one takes precedence)
> 
> SureFire also allows a different JVM to be used:
> 
> <artifactId>maven-surefire-plugin</artifactId>
>   <configuration>
>      <jvm>${JAVA_1_4_HOME}/bin/java</jvm>
> 
> However, the current version of Surefire (2.4.3) does not run under
> 1.3.1; the latest version that seems to support 1.3 is Surefire 2.2,
> so the parent version needs to be overridden with that in the
> component pom.
> 
> So projects requiring Java 1.3 or 1.4 can be compiled and tested under
> Java 1.5+
> 
> But how best to implement this?
> 
> It's important that the POMS still work even if local system only has
> (say) Java 1.5, but it would be nice if Maven automatically chose the
> appropriate compiler if it is available (according to the environment
> variables).
> 
> It would be neat if this could be implemented in the parent pom, but I
> don't know enough about profiles to know if this is possible. Can the
> parent pom refer to variables defined in a child pom?
> 
> What would be ideal is to activate the settings when the component
> profile specifies compiler.source which is different from the JVM
> which is running Maven.  If the appropriate environment variable
> exists (i.e. the compiler exists) then process the settings, otherwise
> report a warning and continue.
> 
> Otherwise, if the overrides can at least be enabled by setting a
> command-line parameter, that would be OK.
> 
> 1]
> http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-
using-different-jdk.html

Another solution should be the animal sniffer: 
http://mojo.codehaus.org/animal-sniffer-maven-plugin/

This should ensures that the generated byte code is using only the API of a 
previously generated signature. There are already signatures for the 
different JREs. This way you could even check for JRE 1.3 compatibility.

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [ALL] Compile and Test under different JVM from Maven

Posted by sebb <se...@gmail.com>.
On 09/03/2010, Niall Pemberton <ni...@gmail.com> wrote:
> First thought this is will overly complicate the maven build.

Depends - if it can be done as a separate profile in the parent pom,
then it should be not too bad.

Seems to me that this will be a recurring problem - at some point
we'll probably have to move to a version of Maven that requires 1.5+
(already the current release requires this, though 1.4 still seems to
be supported).

At which point, do we create Ant builds for all the 1.4 projects? That
could be a lot of work, whereas any work done on the parent pom will
be usable by all components. Once set up for a single JVM, it is
trivial to add others.

>  Also I just restored compatibility for JDK 1.4[1] so its only JDK 1.3.

Yes, thanks, I saw that.

>  We have Ant builds for JDK 1.3 components - can Continuum run Ant?

I think so. If not, Hudson can.

>  Niall:
>
>  [1] http://markmail.org/message/7xlgzzefqsfz4no2
>
>
>  On Tue, Mar 9, 2010 at 1:10 AM, sebb <se...@gmail.com> wrote:
>  > I've done some investigations.
>  >
>  > Maven can happily compile code with Java 1.3 or 1.4 etc. even when
>  > Maven itself runs under Java 1.5+ [1]
>  >
>  > This can be done by adding the following to the component POM:
>  >
>  > <build>
>  >   <plugins>
>  >      <plugin>
>  >        <groupId>org.apache.maven.plugins</groupId>
>  >        <artifactId>maven-compiler-plugin</artifactId>
>  >        <configuration>
>  >          <fork>true</fork>
>  >          <executable>${JAVA_1_3_HOME}/bin/javac</executable>
>  >          <compilerVersion>${maven.compile.source}</compilerVersion>
>  >        </configuration>
>  >
>  > The variable JAVA_1_3_HOME can either be defined as:
>  > + an environment variable
>  > + added to settings.xml or
>  > + defined on the command line
>  > (the above are processed in order, the last one takes precedence)
>  >
>  > SureFire also allows a different JVM to be used:
>  >
>  > <artifactId>maven-surefire-plugin</artifactId>
>  >  <configuration>
>  >     <jvm>${JAVA_1_4_HOME}/bin/java</jvm>
>  >
>  > However, the current version of Surefire (2.4.3) does not run under
>  > 1.3.1; the latest version that seems to support 1.3 is Surefire 2.2,
>  > so the parent version needs to be overridden with that in the
>  > component pom.
>  >
>  > So projects requiring Java 1.3 or 1.4 can be compiled and tested under Java 1.5+
>  >
>  > But how best to implement this?
>  >
>  > It's important that the POMS still work even if local system only has
>  > (say) Java 1.5, but it would be nice if Maven automatically chose the
>  > appropriate compiler if it is available (according to the environment
>  > variables).
>  >
>  > It would be neat if this could be implemented in the parent pom, but I
>  > don't know enough about profiles to know if this is possible. Can the
>  > parent pom refer to variables defined in a child pom?
>  >
>  > What would be ideal is to activate the settings when the component
>  > profile specifies compiler.source which is different from the JVM
>  > which is running Maven.  If the appropriate environment variable
>  > exists (i.e. the compiler exists) then process the settings, otherwise
>  > report a warning and continue.
>  >
>  > Otherwise, if the overrides can at least be enabled by setting a
>  > command-line parameter, that would be OK.
>  >
>  > 1] http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html
>  >
>
> > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>  > For additional commands, e-mail: dev-help@commons.apache.org
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>  For additional commands, e-mail: dev-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [ALL] Compile and Test under different JVM from Maven

Posted by Niall Pemberton <ni...@gmail.com>.
First thought this is will overly complicate the maven build. Also I
just restored compatibility for JDK 1.4[1] so its only JDK 1.3. We
have Ant builds for JDK 1.3 components - can Continuum run Ant?

Niall:

[1] http://markmail.org/message/7xlgzzefqsfz4no2

On Tue, Mar 9, 2010 at 1:10 AM, sebb <se...@gmail.com> wrote:
> I've done some investigations.
>
> Maven can happily compile code with Java 1.3 or 1.4 etc. even when
> Maven itself runs under Java 1.5+ [1]
>
> This can be done by adding the following to the component POM:
>
> <build>
>   <plugins>
>      <plugin>
>        <groupId>org.apache.maven.plugins</groupId>
>        <artifactId>maven-compiler-plugin</artifactId>
>        <configuration>
>          <fork>true</fork>
>          <executable>${JAVA_1_3_HOME}/bin/javac</executable>
>          <compilerVersion>${maven.compile.source}</compilerVersion>
>        </configuration>
>
> The variable JAVA_1_3_HOME can either be defined as:
> + an environment variable
> + added to settings.xml or
> + defined on the command line
> (the above are processed in order, the last one takes precedence)
>
> SureFire also allows a different JVM to be used:
>
> <artifactId>maven-surefire-plugin</artifactId>
>  <configuration>
>     <jvm>${JAVA_1_4_HOME}/bin/java</jvm>
>
> However, the current version of Surefire (2.4.3) does not run under
> 1.3.1; the latest version that seems to support 1.3 is Surefire 2.2,
> so the parent version needs to be overridden with that in the
> component pom.
>
> So projects requiring Java 1.3 or 1.4 can be compiled and tested under Java 1.5+
>
> But how best to implement this?
>
> It's important that the POMS still work even if local system only has
> (say) Java 1.5, but it would be nice if Maven automatically chose the
> appropriate compiler if it is available (according to the environment
> variables).
>
> It would be neat if this could be implemented in the parent pom, but I
> don't know enough about profiles to know if this is possible. Can the
> parent pom refer to variables defined in a child pom?
>
> What would be ideal is to activate the settings when the component
> profile specifies compiler.source which is different from the JVM
> which is running Maven.  If the appropriate environment variable
> exists (i.e. the compiler exists) then process the settings, otherwise
> report a warning and continue.
>
> Otherwise, if the overrides can at least be enabled by setting a
> command-line parameter, that would be OK.
>
> 1] http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org