Issue
I am migrating jenkins plugin project from java 8 to java 11. I'm facing error when I run
mvn install
[ERROR] Failed to execute goal org.jenkins-ci.tools:maven-hpi-plugin:3.17:test-hpl (default-test-hpl) on project XXXX: Unsupported Java version string:
1.11
. If you use Java 9 or above, see https://openjdk.java.net/jeps/223 -> [Help 1].
Any help is greatly appreciated.
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
<repository>
<id>wikimedia.releases</id>
<name>Wikimedia Release Repository</name>
<url>https://archiva.wikimedia.org/repository/releases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.16</version>
<relativePath />
</parent>
<artifactId>gearman-plugin</artifactId>
<packaging>hpi</packaging>
<version>0.5.1-SNAPSHOT</version>
<name>Gearman Plugin</name>
<description>Integrates Gearman application framework with Jenkins</description>
<url>https://plugins.jenkins.io/gearman-plugin/</url>
<licenses>
<license>
<name>Apache License Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>zaro0508</id>
<name>Khai Do</name>
<email>[email protected]</email>
</developer>
<developer>
<id>hashar</id>
<name>Antoine Musso</name>
<email>[email protected]</email>
</developer>
</developers>
<scm>
<connection>scm:git:[email protected]:jenkinsci/gearman-plugin.git</connection>
<developerConnection>scm:git:[email protected]:jenkinsci/gearman-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/gearman-plugin</url>
<tag>HEAD</tag>
</scm>
<properties>
<java.level>11</java.level>
<jenkins.version>2.277.1</jenkins.version>
<gson.version>2.8.2</gson.version>
<gearman.version>0.10</gearman.version>
<hamcrest.version>2.2</hamcrest.version>
<mockito.version>2.28.2</mockito.version>
<powermock.version>2.0.7</powermock.version>
<objenesis.version>3.0.1</objenesis.version>
<jenkins-maven-plugin>3.8</jenkins-maven-plugin>
<slf4j-api>1.7.30</slf4j-api>
<maven.javadoc.skip>true</maven.javadoc.skip>
<findbugs.failOnError>false</findbugs.failOnError>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.235.x</artifactId>
<version>25</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins</groupId>
<artifactId>configuration-as-code</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jenkins.configuration-as-code</groupId>
<artifactId>test-harness</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-test-harness</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>${hamcrest.version}</version>
</dependency>
<dependency>
<groupId>org.wikimedia.gearman</groupId>
<artifactId>gearman-java</artifactId>
<version>${gearman.version}</version>
<exclusions>
<!--
Jenkins brings slf4j-over-slf4j which does the opposite
of slf4j-log4j12.
https://www.slf4j.org/codes.html#log4jDelegationLoop
-->
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>${objenesis.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>maven-plugin</artifactId>
<version>${jenkins-maven-plugin}</version>
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-api}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j-api}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${slf4j-api}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>${slf4j-api}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-api</artifactId>
<version>1.11.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-providers-standard</artifactId>
<version>1.11.2</version>
<type>pom</type>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
<release>11</release>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
</plugins>
</build>
</project>
Solution
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>3.17</version>
<extensions>true</extensions>
<executions>
<execution>
<id>default-hpi</id>
<phase>package</phase>
<goals>
<goal>hpi</goal>
</goals>
<configuration>
<showDeprecation>true</showDeprecation>
<webApp>
<contextPath>/jenkins</contextPath>
</webApp>
<minimumJavaVersion>11</minimumJavaVersion>
<systemProperties>
<hudson.Main.development>true</hudson.Main.development>
</systemProperties>
</configuration>
</execution>
<execution>
<id>default-insert-test</id>
<phase>generate-test-sources</phase>
<goals>
<goal>insert-test</goal>
</goals>
<configuration>
<showDeprecation>true</showDeprecation>
<webApp>
<contextPath>/jenkins</contextPath>
</webApp>
<minimumJavaVersion>11</minimumJavaVersion>
<systemProperties>
<hudson.Main.development>true</hudson.Main.development>
</systemProperties>
</configuration>
</execution>
<execution>
<id>default-test-hpl</id>
<phase>test-compile</phase>
<goals>
<goal>test-hpl</goal>
</goals>
<configuration>
<showDeprecation>true</showDeprecation>
<webApp>
<contextPath>/jenkins</contextPath>
</webApp>
<minimumJavaVersion>11</minimumJavaVersion>
<systemProperties>
<hudson.Main.development>true</hudson.Main.development>
</systemProperties>
</configuration>
</execution>
<execution>
<id>default-resolve-test-dependencies</id>
<phase>test-compile</phase>
<goals>
<goal>resolve-test-dependencies</goal>
</goals>
<configuration>
<showDeprecation>true</showDeprecation>
<webApp>
<contextPath>/jenkins</contextPath>
</webApp>
<minimumJavaVersion>11</minimumJavaVersion>
<systemProperties>
<hudson.Main.development>true</hudson.Main.development>
</systemProperties>
</configuration>
</execution>
<execution>
<id>default-validate</id>
<phase>validate</phase>
<goals>
<goal>validate</goal>
</goals>
<configuration>
<showDeprecation>true</showDeprecation>
<webApp>
<contextPath>/jenkins</contextPath>
</webApp>
<minimumJavaVersion>11</minimumJavaVersion>
<systemProperties>
<hudson.Main.development>true</hudson.Main.development>
</systemProperties>
</configuration>
</execution>
<execution>
<id>default-cli</id>
<goals>
<goal>run</goal>
</goals>
<configuration>
<minimumJavaVersion>11</minimumJavaVersion>
<showDeprecation>true</showDeprecation>
<webApp>
<contextPath>/jenkins</contextPath>
</webApp>
<systemProperties>
<hudson.Main.development>true</hudson.Main.development>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
By overriding the complete hpi plugin dependency I was able to resolve the issue.
Answered By - Geeky
Answer Checked By - Cary Denson (JavaFixing Admin)