Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 904
Avi Avatar asked Oct 02 '13 08:10

Avi


People also ask

How to solve Maven project build lifecycle mapping problem?

Just go to Window->Preferences->Maven->Errors/Warnings and change the warning level for the last element "Plugin execution not covered by lifecycle configuration" to either warning or ignore. What whay do you recommend to run a module when using eclipse+debugging?

What is pluginManagement in Maven?

From Maven documentation: pluginManagement: is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one.

What are the Maven lifecycle phases?

Maven Lifecycle: Below is a representation of the default Maven lifecycle and its 8 steps: Validate, Compile, Test, Package, Integration test, Verify, Install and Deploy.


1 Answers

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>
like image 123
Felipe Balduino Cassar Avatar answered Oct 24 '22 17:10

Felipe Balduino Cassar