I want to perform a maven release that compile java 1.8 code on a Jenkins install that runs on jdk 1.7
I have a project that I compile with java 1.8 using the JDK Parameter Plugin . It works when doing a regular build.
When I do a maven release using the maven release plugin, it forks a JVM with java 1.7 instead of the version specified on the plugin. I guess that it takes the java version in the environment.
If I set JAVA_HOME for that job to 1.8 it works.
I am trying to find a solution where I don't have to override the JAVA_HOME in all my jobs.
I tried to use the solution from a similar post which fixed OP problem by forcing a compiler version:
<properties>
<jee.level>1.8</jee.level>
<jdk.level>1.8</jdk.level>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${jee.level}</source>
<target>${jdk.level}</target>
</configuration>
</plugin>
but I end up with:
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project redeem-commons-test: Fatal error compiling: invalid target release: 1.8 -> [Help 1]
any help would be appreciated.
The best solution I found so far is to upgrage the JDK of the container in which jenkins runs and add a JAVA_OPTS to the latter to support the previous JDK version. e.g. -Djava.version=1.7
This way I can build and maven release projects that are java 7 or java 8.