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

eclipsem2em2eclipsemavenmaven-3

I am configuring a multi-module parent child maven project using maven and eclipse m2e, I am using the latest stuff from eclipse Juno SR1 which is m2e 1.2.0

the parent pom uses the enforcer plugin, so the parent pom.xml has the following in its plugin section

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <version>1.1.1</version>
    <executions>

        <!-- Enforce that all versions of a transative dependency must converge. -->
        <execution>
            <id>enforce</id>
            <configuration>
                <rules>
                    <DependencyConvergence />
                </rules>
            </configuration>
            <goals>
                <goal>enforce</goal>
            </goals>
        </execution>

        <!-- Black list certain jars -->
        <execution>
            <id>enforce-banned-dependencies</id>
            <goals>
                <goal>enforce</goal>
            </goals>
            <configuration>
                <rules>
                    <bannedDependencies>
                        <excludes>
                            <exclude>
                                commons-logging:commons-logging
                            </exclude>
                        </excludes>
                    </bannedDependencies>
                </rules>
                <fail>true</fail>
            </configuration>
        </execution>

    </executions>
</plugin>

Each of the child projects has an error message saying maven-enforcer-plugin (goal "enforce") is ignored by m2e.

  • What is the meaning of this message?
  • How do I configure things to get rid of this message?
  • do I need to configure the eclipse project settings or the pom.xml settings?

Best 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.

Related Topic