How can I map Maven lifecycle phases not covered by the Eclipse m2e plugin?

21,654

M2Eclipse (the Maven integration plugin for Eclipse) is mapping and execution the default phases and goals of Maven into the internal Eclipse build workflow.

See: https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html

[...] requires explicit instructions what to do with all Maven plugins bound to “interesting” phases [...] of a project build lifecycle. We call these instructions “project build lifecycle mapping” or simply “lifecycle mapping” because they define how m2e maps information from project pom.xml file to Eclipse workspace project configuration and behaviour during Eclipse workspace build.

It is possible to solve this errors in every project or in your global Eclipse installation.

Project build lifecycle mapping can be configured in a project’s pom.xml, contributed by Eclipse plugins, or defaulted to the commonly used Maven plugins shipped with m2e. We call these “lifecycle mapping metadata sources”.

The global Eclipse setting file is called lifecycle-mapping-metadata.xml and configurable via the 'Lifecycle Mappings' at the Maven Settings dialog[1].

M2Eclipse matches plugin executions to actions using combination of plugin groupId, artifactId, version range and goal. There are three basic actions that M2Eclipse can be instructed to do with a plugin execution – ignore, execute and delegate to a project configurator.

[...]

The ignore option, as the name suggests, tells M2Eclipse to silently ignore the plugin execution.

[...]

The execute option tells m2e to execute the action as part of Eclipse workspace full or incremental build.

delegate to a project configurator means there are adapter Eclipse plugins in the Eclipse Marketplace. A adapter plugin executes the phases and goals in a more Maven plugin specific way.

The real settings (the XML structure) isn't real intuitive but a bit described in the link above.

In your case the lifecycle-mapping-metadata.xml will be looks like:

<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
  <pluginExecutions>
[...]
    <pluginExecution>
      <pluginExecutionFilter>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <versionRange>[1.0-alpha-2,)</versionRange>
        <goals>
          <goal>write-project-properties</goal>
        </goals>
      </pluginExecutionFilter>
      <action>
        <ignore />
      </action>
    </pluginExecution>
[...]
  </pluginExecutions>
</lifecycleMappingMetadata>

ProTip: Did you have more projects and use a set of Maven plugins all the time, move the lifecycle-mapping-metadata.xml in SCM (git, svn, cvs ...).

EDIT

Add all goals of a plugin and maybe additional plugins to avoid these errors. Read the error message carefully for additional goals or plugins.

After any saved change of lifecycle-mapping-metadata.xml you have to reload the content in the Maven Settings dialog[1] and update all Maven based projects in the workspace.

Click the right mouse button on a Maven project in your Workspace and choose Maven > Update Projects .... Select the/all Maven Projects and activate the following checkboxes:

  • Update project configuration from pom.xml
  • Refresh workspace resources from local filesystem
  • Clean projects

EDIT

[1] The Maven Settings dialog was located at File > Window > Preferences > Maven > Lifecycle Mappings until Exclipse Oxygen.

Share:
21,654
Dave
Author by

Dave

Updated on July 09, 2022

Comments

  • Dave
    Dave almost 2 years

    I’m using Eclipse Kepler on Mac 10.9.5. I have imported a number of Maven projects using the m2e Eclipse plugin. All these projects are children of a parent pom. When I look at the “Overview” in the individual child pom.xml files, I see stuff like this:

    Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties (execution: default, phase: process-resources)
    

    I would like Eclipse to execute these lifecycle phases at the appropriate times, but I’m not sure how to do that. When I select Eclipse’s suggestion …

    Permanently mark goal write-project-properties in pom.xml as ignore
    

    I selected the parent pom.xml file when prompted “Select location to place ignore,” however, the error does not go away when I view the child pom.xml file in the Eclipse editor. How can I map lifecycle phases not covered by m2e?

    Edit:

    Per the answer, I went to Eclipse -> Preferences -> Maven -> Lifecycle Mappings, clicked on "Open Workspace Lifecycle Mappings Metadata", and edited the file as suggested ...

    <?xml version="1.0" encoding="UTF-8"?>
    <lifecycleMappingMetadata>
        <pluginExecutions>
            <pluginExecution>
                <pluginExecutionFilter>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>xmlbeans-maven-plugin</artifactId>
                    <versionRange>2.3.3</versionRange>
                    <goals>
                        <goal>xmlbeans</goal>
                    </goals>
                </pluginExecutionFilter>
                <action>
                    <ignore />
                </action>
            </pluginExecution>
            <pluginExecution>
                <pluginExecutionFilter>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>properties-maven-plugin</artifactId>
                    <versionRange>[1.0-alpha-2,)</versionRange>
                    <goals>
                        <goal>write-project-properties</goal>
                    </goals>
                </pluginExecutionFilter>
                <action>
                    <execute />
                </action>
            </pluginExecution>
        </pluginExecutions>
    </lifecycleMappingMetadata>
    

    Even after restarting Eclipse, when I open a child pom.xml file, the "Plugin execution not covered by lifecycle configuration" errors remain as before.

  • Dave
    Dave almost 9 years
    I edited my question to show what happened when I edited the file as you suggested (I put "execute" instead of "ignore"). but the "Plugin not covered by lifecycle" errors remain.
  • barthel
    barthel almost 9 years
    It's exact the same error or different goals? You have to add all not mapped goals and maybe other plugins too.
  • Grim
    Grim almost 8 years
    @barthel The ProTip ... where to place lifecycle-mapping-metadata.xml? / or /src or where?
  • barthel
    barthel almost 8 years
    @PeterRader For more than one project use a dedicated project like eclipse-settings or similar and configure like described above. It's also possible to include the lifecycle settings into the POM file. Take a look at: eclipse.org/m2e/documentation/…
  • barthel
    barthel over 7 years
    @peterh Why downvote? Check the date of my answer! How old is Eclipse Oxygen?
  • peterh
    peterh over 7 years
    @barthel O.k., thanks the extension! I am sorry for the trouble. In the Java things I find quite often bad answers and these made me a little bit sensitive to them.
  • mirec
    mirec over 7 years
    @barthel, what does it mean "silently ignore the plugin execution"? Does it mean goal is not executed? <ignore/> would be in no case acceptable choice then...
  • barthel
    barthel over 7 years
    @mirec This is a quote from the eclipse website. <ignore /> means that this goal will not executed. There are some cases where a goal has to skiped within Eclipse Lifecycle. The project strategies of Eclipse and Maven doesn't match perfectly.