'Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain
I am using m2e to build a java project. I need to use JAVA VERSION 1.6 . So i am trying to configure toolchains plugin to achieve it. by referring the below link.
https://maven.apache.org/guides/mini/guide-using-toolchains.html
But in eclipse it is throwing the below error.
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain (execution: default, phase: validate) pom.xml /Replenishment line 98 Maven Project Build Lifecycle Mapping Problem
I referred the link but i did not get a proper clarity. Below is the code snippet used for configuring tool chains plugin.
IN pom.XML
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-toolchains-plugin
</artifactId>
<versionRange>
[1.1,)
</versionRange>
<goals>
<goal>toolchain</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>1.6</version>
<vendor>sun</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
and my toolchains.xml
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<!-- JDK toolchains -->
<toolchain>
<type>jdk</type>
<provides>
<version>1.6</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>D:\POC\jdk1.6.0_31</jdkHome>
</configuration>
</toolchain>
</toolchains>
Solution 1:[1]
The error got resolved after changing my pom.xml file like below. We need to add the maven life cycle plugin and then include the metadata information in the .
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>1.6</version>
<vendor>sun</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-toolchains-plugin
</artifactId>
<versionRange>
[1.1,)
</versionRange>
<goals>
<goal>toolchain</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Solution 2:[2]
For eclipse users, Go to Window >> Preferences >> Maven .
Select Lifecycle Mapping option from menu. The default mapping file location could be in somewhere in eclipse temp directory, instead copy the file lifecycle-mapping-metadata.xml file to some location in eclipse directory or maven directory so that it could be easy to refer.
In lifecycle-mapping-metadata.xml file add below configuration.
<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<versionRange>[0.5,)</versionRange>
<goals>
<goal>prepare-agent</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<goals>
<goal>toolchain</goal>
</goals>
<versionRange>[0.0,)</versionRange>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
Just do Maven >> Update Project from project view. This is the easy way to solve the issue.
Solution 3:[3]
Instead of adding the life cycle plugin separately, it can be solved directly by adding <pluginmanagement>
tag before the <plugins>
tag as given below.
<build>
<pluginManagement>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<lifecycleMappingMetadata>
......................
......................
</pluginManagement>
</build>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Aravind |
Solution 2 | Gunwant |
Solution 3 | vijaidhas |