Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure toolchains plugin in m2e / Installed maven in Eclipse

Currently i am using maven(Apache Maven 3.3.9) & Java(Java version: 1.8.0_91) installed in my windows machine. I have a java application which was developed using Java Version 1.6.0_31.

Since Apache maven(3.3.9) is not directly compatible with the previous version of Java(Prior to 1.8) I have included toolchains plugin to compile and run the project with Java 1.6. I can do a successful build using command prompt.

But when I try to build the same project using eclipse with eclipse m2e plugin or by adding the external maven(3.3.9) using eclipse->Windows->Preferences->Maven->Installations, I am getting the below error.

[WARNING] 
[WARNING] Some problems were encountered while building the effective settings
[WARNING] Expected root element 'settings' but found 'toolchains' (position: START_TAG seen ...OOLCHAINS/1.1.0 http://maven.apache.org/xsd/toolchains-1.1.0.xsd">... @45:114)  @ U:\POC\Repo\.m2\toolchains.xml, line 45, column 114
[WARNING] 
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Replenishment Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Replenishment ---
[INFO] Deleting C:\Users\xagh9\workspace\Replenishment\target
[INFO] 
[INFO] --- maven-toolchains-plugin:1.1:toolchain (default) @ Replenishment ---
[INFO] Required toolchain: jdk [ vendor='sun' version='1.6' ]
[ERROR] No toolchain found for type jdk
[ERROR] Cannot find matching toolchain definitions for the following toolchain types:
jdk [ vendor='sun' version='1.6' ]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.105 s
[INFO] Finished at: 2017-01-04T12:02:08+11:00
[INFO] Final Memory: 8M/116M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain (default) on project Replenishment: 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.
[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

Note: With Java_1.8 I can build the project successfully without toolchains plugin. But with toolchains plugin configured I am facing this issues. Can anyone help me to resolve this.

The required toolchains.xml is present in both maven config folder as well as in the .m2 folder of the repository

UPDATE: Maven compiler plugin configuration: Plugin

like image 952
Aravind Avatar asked Jan 03 '17 23:01

Aravind


People also ask

What is Maven Toolchains plugin?

What is Toolchains? The Maven Toolchains provide a way for plugins to discover what JDK (or other tools) are to be used during the build, without the need to configure them in each plugin nor in every pom. xml , or forcing a precise location among every machine building the project.

What are Maven plugins used for?

The Maven Plugin Plugin is used to create a Maven plugin descriptor for any Mojo's found in the source tree, to include in the JAR. It is also used to generate report files for the Mojos as well as the artifact metadata and generating a generic help goal.


1 Answers

The resolved after changing goals in eclipse run configuration as below.

Eclipse run configuration

The problem is eclipse is not automatically reading the toolchains.xml. We have to manually specify in the goals. I fixed this by referring the this Link

like image 178
Aravind Avatar answered Sep 20 '22 23:09

Aravind