Home > OS >  maven build works on windows but fails on linux
maven build works on windows but fails on linux

Time:01-02

I use the azure pipeline to build the java spring boot app using maven. when I run the pipeline on a windows machine works fine but when I use a Linux machine gives me error.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project java-app: Compilation failure: Compilation failure: 
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

how can i slove this problem ?

CodePudding user response:

You have different java versions on Windows, Linux. More recent versions can only downgrade up to 1.6 but not 1.5. so I assume on your Linux is a JDK 11 while on your Windows a JDK 8 or less.

However maven standard is still java 1.5, if you do not override it. Look into the other answer from @khmarbaise.

maven takes Java 1.5 default even if JAVA_HOME is set to JDK11

CodePudding user response:

You have to define a more up-to-date maven-compiler-plugin like this:

<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.10.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
    [...]
  </build>
  [...]
</project>

I would suggest to use <release>8</release> depending on your used JDK..Also I would suggest to use the most recent version of Maven

  • Related