Fixing Maven Execution Error Markers in Eclipse

A common problem I have with eclipse is adding plugins to my maven pom and seeing the dreaded red squiggly error line rear its ugly head. The accompanying text kindly informs me that “Plugin execution not covered by lifecycle configuration”.

This simply means that m2e (the eclipse maven integration) doesn’t know how to handle this plugin. I’ve found two ways to bypass this error. I’ll detail both methods below:

1. Bind to a different lifecycle phase

M2e only seems to be concerned by plugins bound to the “Compile” lifecycle phase or earlier. If possible, try binding your plugin executions to a later lifecycle phase. An example of this is below:

<build>
  <plugins>
    <plugin>
     <groupId>org.jibx</groupId>
     <artifactId>jibx-maven-plugin</artifactId>
     <version>1.2.4.5</version>
     <executions>
       <execution>
         <goals>
         <goal>bind</goal>
         </goals>
         <phase>test</phase>
       </execution>
     </executions>
    </plugin>
  </plugins>
</build>

2. Exclude the plugin from M2e’s executions

By adding the following code, you can exclude plugins from M2e’s execution (this doesn’t affect your command line maven build)

<!-- Fix for certain plugins not being supported in eclipse. This gets rid of the error marker -->

<pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.eclipse.m2e</groupId>
      <artifactId>lifecycle-mappings</artifactId>
      <version>1.0.0</version>
      <configuration>
        <lifecycleMappingMetadata>
          <pluginExecutions>
            <pluginExecution>
              <pluginExecutionFilter>
                <groupId>org.jibx</groupId>
                <artifactId>jibx-maven-plugin</artifactId>
                <versionRange>[1.0,)</versionRange>
                <goals>
                  <goal>bind</goal>
                </goals>
              </pluginExecutionFilter>
              <action>
                <ignore />
              </action>
            </pluginExecution>
          </pluginExecutions>
        </lifecycleMappingMetadata>
      </configuration>
    </plugin>
  </plugins>
</pluginManagement>

<!-- End Fix -->

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s