Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven build error after setting toolchain right

I have Java version 1.8.111 installed and the initial error message after running mvn3 install was as below.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain (default) on project myfile: Cannot find matching toolchain definitions for the following toolchain types:
[ERROR] jdk [ vendor='sun' version='1.6' ]
[ERROR] Please make sure you define the required toolchains in your ~/.m2/toolchains.xml file.

To resolved this, I've updated my toolchains.xml to version 1.8.111 but still getting the same error. I've also tried after running mvn3 clean and successfully cleaned but still getting the same error.

Could anyone pinpoint where this version 1.6 is fetched from? I checked JAVA_HOME already, it's set to 1.8.

Can anyone explain how maven calls Java version?

Appreciate your help.

Below is my toolchains.xml enter image description here

like image 685
haeminish Avatar asked Nov 01 '16 06:11

haeminish


1 Answers

Your application is expected to be built with JDK 1.6 and to locate it Maven is looking for definition of [ vendor='sun' version='1.6' ] within toolchains.xml in your {home}/.m2/ directory (see eg this maven guide). You just need to point to it and all should be good.

<?xml version="1.0" encoding="UTF8"?>
<toolchains>
  <toolchain>
    <type>jdk</type>
    <provides>
      <version>1.6</version>
      <vendor>sun</vendor>
    </provides>
    <configuration>
       <jdkHome>/Library/Java/JavaVirtualMachines/jdk1.6.X_XX.jdk/Contents/Home</jdkHome>
    </configuration>
  </toolchain>
</toolchains>
like image 153
gerasoras Avatar answered Nov 07 '22 20:11

gerasoras