Skip to main content

Maven jobs and Java versions compatibility

Comments

7 comments

  • Bollapu Harinathareddy

    Hi, 

    I am facing similar issue in Jenkins 2.18 version, will you please is this solution will work or not. I am using maven 3.3.3 and JDK 1.8. 

     

    Thanks in advance Harinatha

     

    0
  • Arnaud Héritier

    Hi Bollapu,

     

      Yes the principle remains the same. If you have this error this is because you configured a Maven job with a Java version < 7. Jenkins >= 1.612 and thus 2.18 cannot natively use Maven jobs with a Java version inferior to 7. THus the build is trying to use the Java version of your agent which is necessarily superior or equal to 7.

     

    Best regards

    0
  • Oleg Nenashev

    This guide is a bit outdated. If you use CJE based on Jenkins LTS 2.60.x or newer, Java 8 is required in the case of Maven Jobs. It is documented on the plugin Wiki page: https://wiki.jenkins.io/display/JENKINS/Maven+Project+Plugin

    0
  • Arnaud Héritier

    It was fixed Oleg. Thanks

    0
  • Fenix32 Gonz

    Hi, I am updating from Jenkins 1.624.4 to 2.89.2 with my projects on JDK1.6.

    In my poms

                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                </plugin>

    I made them work creating new FreeStyle-Jobs configured as JDK1.6 without -Dmaven.compiler.source=1.6 -Dmaven.compiler.target=1.6. I have some questions

    • Is it necessary/recommendable to continue with The toolchains solution?
    • Could I use Maven-Jobs instead FreeStyle-Jobs after apply The toolchains solution?

     

    Thank you a lot for the tutorial and the help ^_^

    0
  • Arnaud Héritier

    Hi Fenix,

      As you configured the maven compiler in the pom you effectively don't need to use 

    -Dmaven.compiler.source=1.6 -Dmaven.compiler.target=1.6

      No the toolchain solution isn't mandatory and is useful only if you want to come back to use Maven-Jobs instead FreeStyle-Jobs. By using toolchains you'll be able to use Maven-Jobs by letting them running on Java 8 (required by jenkins) but all tools (javac, javadocs, ...) will use Java 6. Using a freestyle project with Java 6 give you the same result if you don't need absolutely some features provided by the Maven jobs.

    BR.

    0
  • Jesse Glick

    The resolution

    All Maven Jobs have to be configured to use at the minimum the version required by Jenkins

    is incorrect. The whole point of the message printed in the build log

    Retrying with slave Java and setting compile/test properties to point to <path_to_the_java_vm-used_by_your_slave>.

    is that you do not have to do anything, in the common case: if your Maven project is configured with a JDK older than the minimum currently required by Jenkins controllers & agents, then the Maven plugin for Jenkins will automatically relaunch the Maven JVM with a newer Java runtime but configure common Maven mojos to actually use your configured JDK for build steps.

    This automated workaround may not be complete, depending on the details of your project. See https://issues.jenkins.io/browse/JENKINS-68878?focusedCommentId=427502&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-427502 for a case where a JAX-WS issue in Jenkins 2.357 (requiring Java 11) was resolved by updating a mojo version in the POM.

    When you have time to do it, the recommendation is to switch to Pipeline. https://plugins.jenkins.io/pipeline-maven/ provides much of the functionality of the Maven plugin for Jenkins in a more sustainable way.

    0

Please sign in to leave a comment.

About CloudBees Support

Our Support Engineers are available to help with any questions or problems you may have with any of our products.