Plugin maven-antrun-plugin execution not covered by lifecycle configuration with m2e

Avi picture Avi · Oct 2, 2013 · Viewed 8k times · Source

I know this has been asked before but I'm still struggling on solving this issue. When I load projects into eclipse I get the following exception:

Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-antrun-plugin:1.7:run (execution: generate-webapp-name, phase: compile)

My maven project consists of many modules (>200) and it causes problems on all of them.

I tried ignoring the run and compile goals in my pom.xml (in the parent module):

<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-antrun-plugin</artifactId>
                                <versionRange>[1.7,)</versionRange>
                                <goals>
                                    <goal>compile</goal>
                                    <goal>run</goal>
                                </goals>
                            </pluginExecutionFilter>
                            <action>
                                <ignore/>
                            </action>
                        </pluginExecution>
                    </pluginExecutions>
                </lifecycleMappingMetadata>
            </configuration>
        </plugin>
    </plugins>
</pluginManagement>

But it still doesn't work.

Answer

Felipe Balduino Cassar picture Felipe Balduino Cassar · Sep 26, 2016

You have to specify that the goal that you set for your maven-antrun-plugin (in my case, run) should be executed. For anyone that get to this page, add this code before the plugins tag:

<pluginManagement>
    <plugins>
        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
        <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-antrun-plugin</artifactId>
                                <versionRange>[1.7,)</versionRange>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </pluginExecutionFilter>
                            <action>
                                <execute />
                            </action>
                        </pluginExecution>
                    </pluginExecutions>
                </lifecycleMappingMetadata>
            </configuration>
        </plugin>
    </plugins>
</pluginManagement>

Source here

For what is worth, I'm using a very simple ant code. The plugin code I'm using is this one below. I used the deploy phase, but you can use another one if you want

<plugins>
    <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.8</version>
        <executions>
            <execution>
                <id>antrun.package</id>
                <phase>deploy</phase>
                <goals>
                    <goal>run</goal>
                </goals>
                <configuration>
                    <target>
                        <mkdir dir="${destinationBasePath}/WEB-INF/classes"/> 
                        <copy todir="${destinationBasePath}\WEB-INF\classes">
                            <fileset dir="${basedir}/target/classes" includes="**" />
                        </copy>
                    </target>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>