Reputation: 7228
Recently I have upgraded spring batch project from java 8 to 11.
It works fine locally, and I decided to push to the Jenkins, but I get the following error.
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project bandwidth:
Fatal error compiling: invalid flag: --release -> [Help 1]
What should be the cause, and how can I solve it?
Old setting: java 8 in pom
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<org.springframework-version>3.1.1.RELEASE</org.springframework-version>
<org.springframework.batch>2.1.9.RELEASE</org.springframework.batch>
<org.slf4j-version>1.6.2</org.slf4j-version>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>iso-8859-1</encoding>
</configuration>
</plugin>
New setting: java 11 in pom
<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.springframework-version>3.1.1.RELEASE</org.springframework-version>
<org.springframework.batch>2.1.9.RELEASE</org.springframework.batch>
<org.slf4j-version>1.6.2</org.slf4j-version>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
<encoding>iso-8859-1</encoding>
</configuration>
</plugin>
Upvotes: 2
Views: 19197
Reputation: 7228
The problem was with the Jenkins setting which fallback on default system JDK.
I did add the following and corrected Jenkins pointing to JDK 11.
<properties>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<properties>
Thanks to @naman putting me to the right direction.
Upvotes: 2