I am running Jenkins ver. 1.532. I have created a maven job and tried to configure it to run java 5 using the jenkins JDK auto installer configured to download/install jdk5 from oracle. But when I run the build I get:
ERROR: [JENKINS-18403] JDK 5 not supported to run Maven; retrying with slave Java and setting compile/test properties to point to /var/jenkins/tools/hudson.model.JDK/jdk5
maven31-agent.jar already up to date
maven31-interceptor.jar already up to date
maven3-interceptor-commons.jar already up to date
[my-project] $ /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java -cp /var/jenkins/maven31-agent.jar:/var/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven/boot/plexus-classworlds-2.4.2.jar:/var/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven/conf/logging jenkins.maven3.agent.Maven31Main
It seems that it falls back to building with jdk7 (the default). I have then tried to add the following to the Builds/Goals and options section:
mvn clean install -Dmaven.compiler.executable=/var/lib/jenkins/tools/hudson.model.JDK/jdk5/bin/javac
But it does not have any effect. Should it not be possible to force a JDK version using -Dmaven.compiler.executable
option?
EDIT: I have now switched to the jenkins freestyle project type and use the maven-enforcer-plugin to fail the build if a jdk != 1.5 is used when building the project. See last paragraph here:
https://blogs.oracle.com/darcy/entry/how_to_cross_compile_for
and Note here:
http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html