AspectJ – Plugin execution not covered by lifecycle configuration error in Eclipse

When you open your AspectJ project in Eclipse with the m2eclipse, the following error may appear.

  • Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:aspectj-maven-plugin…

 

This is because m2e doesn’t provide lifecycle mapping for aspectj-maven-plugin. A work around is to add the following <pluginManagement> setting in the pom.xml.

...
<build>
  <pluginManagement>
    <!-- Fix AspectJ lifecycle error in eclipes -->
    <plugins>
      <plugin>
        <groupId>org.eclipse.m2e</groupId>
        <artifactId>lifecycle-mapping</artifactId>
        <version>1.0.0</version>
        <configuration>
          <lifecycleMappingMetadata>
            <pluginExecutions>
              <pluginExecution>
                <pluginExecutionFilter>
                  <groupId>org.codehaus.mojo</groupId>
                  <artifactId>aspectj-maven-plugin</artifactId>
                  <versionRange>[1.0,)</versionRange>
                  <goals>
                    <goal>test-compile</goal>
                    <goal>compile</goal>
                  </goals>
                </pluginExecutionFilter>
                <action>
                  <execute />
                </action>
              </pluginExecution>
            </pluginExecutions>
          </lifecycleMappingMetadata>
        </configuration>
      </plugin>
    </plugins>
  </pluginManagement>

  <!-- Other config -->
<build>
...

 

This solution applies to any Maven plugins, ex. the svn-revision-number-maven-plugin, which throw the Plugin execution not covered by lifecycle configuration error.

Done =)

Reference: StackOverflow – aspectj not recognized in Maven plugin

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s