Java – Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain

eclipsejavamavenxml

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>

Best Answer

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.

lifecycle-mapping-metadata

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.

Related Topic