score:56

Accepted answer

The eclipse maven plugin runs a projects pom.xml file in order figure out how the maven project is configured and translate the maven pom.xml configuration into an eclipse configuration. A pom.xml can reference an arbitrary number of maven plugins and each of those plugins has the potential to leak memory, or do things that are harmful to eclipse. So by default the m2e eclipse plugin ignores any maven plugins unless those maven plugins have a special m2e plugin connector that tells m2e how to integrate the maven plugin into eclipse. In summary m2e is defending the eclipse JVM process against a buggy maven plugin, by saying that for every maven plugin there needs to be an m2e connector to bridge between maven and eclipse.

So to get rid of the warning I added the following to my plugin management section of the parent pom.xml

<build>
  <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-enforcer-plugin</artifactId>
                  <versionRange>[1.0.0,)</versionRange>
                  <goals>
                    <goal>enforce</goal>
                  </goals>
                </pluginExecutionFilter>
                <action>
                  <ignore />
                </action>
              </pluginExecution>
            </pluginExecutions>
          </lifecycleMappingMetadata>
        </configuration>
      </plugin>
    </plugins>
  </pluginManagement>
</build>

It seems that org.eclipse.m2e:lifecycle-mappingis a maven plugin designed to hold meta data to communicate with eclipse m2e plugin when it processes a maven pom.xml and this information is used to tell eclipse what do with maven plugins that are defined in pom.xml when eclipse runs the pom.xml as part of the eclipse UI.

score:0

For me it was similar issue

I had maven 3.0.3 and java 1.5

and my pom had

<executions>
                    <execution>
                        <id>enforce-versions</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>[3.0.3,2.2.1,)</version>
                                </requireMavenVersion>
                                <requireJavaVersion>
                                    <version>[1.7, 1.8)</version>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

As you can see I dont really have met rules, hence I updated Java and got mvn going and I was all set. Hope this helps someone.

score:0

Another pitfall exists when having several pluginExecutionFilters. These must be at the right spot in the pom.xml! For me it was gnarly to find as no error or warning of the displacement existed.

This is the right code for having several pluginExecutionFilters:

<build>
  <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-enforcer-plugin</artifactId>
                        <versionRange>[1.0.0,)</versionRange>
                        <goals>
                           <goal>enforce</goal>
                        </goals>
                    </pluginExecutionFilter>
                    <action><ignore/></action>
                </pluginExecution>
<!-- now here follows the new filter -->
                <pluginExecution>
                    <pluginExecutionFilter>
                        <groupId>com.googlecode.maven-java-formatter-plugin</groupId>
                        ...

score:0

How to eliminate the “maven-enforcer-plugin (goal ”enforce“) is ignored by m2e” warning by eclipse?

Although the eclipse lifecycle-mapping plugin has worked for me on other projects, I can't change the pom.xml since I am currently working in an IntelliJ shop with my covert instance of Eclipse and I don't want to expose myself by changing all of their pom files to include anything from group org.eclipse.m2e.

After some experimentation, I've found that you can get this warning to not show up by changing the Lifecycle Mappings in the Maven preferences. Frankly I'm not 100% sure what this is doing but I've not seen any side effects so...

  1. In Eclipse, go to: Preferences → Maven → Lifecycle Mappings.
  2. Clicking Open workspace lifecycle mappings metadata which will open the lifecycle-mapping-metadata.xml file in a tab in the background. I assume that this cooresponds to the following file under your workspace subdir:

    .metadata/.plugins/org.eclipse.m2e.core/lifecycle-mapping-metadata.xml
    
  3. Next add the following stanza to the bottom of the file inside of <pluginExecutions>...</pluginExecutions>.

    <pluginExecution>
        <pluginExecutionFilter>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <versionRange>[1.0.0,)</versionRange>
            <goals>
                <goal>enforce</goal>
            </goals>
        </pluginExecutionFilter>
        <action>
            <ignore />
        </action>
    </pluginExecution>
    
  4. Once the XML file is saved you will need to go back to the preferences window and press Reload workspace lifecycle mappings metadata which compiles the file somehow.

  5. Finally you will need to do a maven update-project on all of your projects to see the warnings go away.

Hope this helps.

score:2

Just an FYI for those of you that have an issue with configuring your IDE in your build model. Keep an eye on this enhancement request currently targeted for the Kepler release:

Bug 350414: Store ignored m2e connectors outside project pom.xml https://bugs.eclipse.org/bugs/show_bug.cgi?id=350414

score:4

From m2e version 1.4 and higher: You can integrate the needed lifecycle-configuration within the pom (parent-pom or project-pom) or you can integrate the informations into the global m2e-configuration within eclipse. Also you have some quickfix-actions for applying this changes.

The last option is to look for m2e-connectors or to switch over to newer versions of different maven-plugins with integrated m2e-support (e.g. for jaxb-plugins).

Here (for enforcer-plugin) I think, the definition in the pom is the easiest way.

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


Related Query

More Query from same tag