[GeoNetwork-devel] GeoNetwork, Maven, and Java 1.5

hello list,

we try to build GeoNetwork so it’s compatible with Java 1.5, by using this in the root pom:

1.5 1.5

However, this does not mean that the build will fail if our code uses 1.6 language, and you have JDK 1.6 as you default. Says the Maven documentation (see http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html):

Note: Merely setting the target option does not guarantee that your code actually runs on a JRE with the specified version. The pitfall is unintended usage of APIs that only exist in later JREs which would make your code fail at runtime with a linkage error. To avoid this issue, you can either configure the compiler’s boot classpath to match the target JRE or use the Animal Sniffer Maven Plugin to verify your code doesn’t use unintended APIs.”

Another way to deal with this in Maven (see http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html) is to use

          <fork>true</fork>
          <executable><!-- path-to-javac --></executable>

          <compilerVersion>1.3</compilerVersion>

which is of course impractical as we all have different paths to the 1.5 javac.

So how can we use Maven to build, and be sure it can run on a 1.5 runtime ? Other than making sure we build on a machine that does not have JDK 1.6 installed, it beats me.

Please advice

Kind regards
Heikki Doeleman