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

1

9

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.

Aggravation answered 2/10, 2013 at 8:8 Comment(7)
What is the expected behavior?Gilt
@Gilt - There's no expected behaviour. I just want to import the projects to eclipse and don't see the exception I mentioned. The pom.xml code I provided was taken from a similiar question (with other plugin) that explained the problem and why it's happening. I followed the different questions but the problem remains.Aggravation
Try selecting all of the projects, then right-click and choose Maven --> Update Projects... and see if that helps.Gilt
@Gilt - First thing I did, a lot before posting a question ;)Aggravation
Always good to eliminate the obvious first. Try this next. Open a command line window, cd to the top project directory, then run mvn clean install (outside of Eclipse). Then, go back to Eclipse, select all of the projects, and refresh them.Gilt
Also did that :/ Also I ran mvn eclipse:clean and mvn eclipse:eclipse, nothing :/Aggravation
Suggest editing your question to list all of the things you have tried. Also, are you using m2e or m2eclipse? They are not the same, and using mvn eclipse:eclipse could actually be harmful.Gilt
A
7

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>
Abisha answered 26/9, 2016 at 21:0 Comment(2)
Thanks for your answer. I can't accept it because it was 3 years ago. I already switched 2 workplaces since and I don't have how to reproduce it (nor do I remember this issue). Thanks for your answer. Hope others will find it useful :)Aggravation
No problem. The intention was really to help the new visitors. I spent a lot of time trying to figure this solution; hope others can find it quicker.Abisha

© 2022 - 2024 — McMap. All rights reserved.