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.

Community
  • 1
  • 1
Avi
  • 21,182
  • 26
  • 82
  • 121
  • What is the expected behavior? – user944849 Oct 02 '13 at 12:47
  • @user944849 - 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. – Avi Oct 02 '13 at 12:49
  • Try selecting all of the projects, then right-click and choose `Maven --> Update Projects...` and see if that helps. – user944849 Oct 02 '13 at 12:56
  • @user944849 - First thing I did, a lot before posting a question ;) – Avi Oct 02 '13 at 13:05
  • 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. – user944849 Oct 02 '13 at 13:39
  • Also did that :/ Also I ran `mvn eclipse:clean` and `mvn eclipse:eclipse`, nothing :/ – Avi Oct 02 '13 at 13:49
  • 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. – user944849 Oct 02 '13 at 14:58

1 Answers1

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>
  • 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 :) – Avi Sep 26 '16 at 21:55
  • 1
    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. – Felipe Balduino Cassar Sep 26 '16 at 23:23