commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörg Schaible <joerg.schai...@gmx.de>
Subject Re: [ALL] Compile and Test under different JVM from Maven
Date Tue, 09 Mar 2010 14:48:15 GMT
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


Mime
View raw message