1

I'm trying to build a project from a POM file using the command:

mvn clean install

But I keep getting this error:

Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-antrun-plugin:1.3:run (execution: build, phase: compile)

It seems Eclipse does not have a plugin for Ant in its app store. How can I resolve this?

Here is the plugin section of my pom.xml file in question:

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
        <execution>
            <id>build</id>
            <phase>compile</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <tasks>
                    <!-- Use exec instead of ant as src/ant/.ant.properties needs to be read in -->
                    <exec executable="ant" osfamily="unix" dir="${basedir}/src" failonerror="true">
                        <arg line="jar" />
                    </exec>
                    <exec executable="cmd" osfamily="windows" dir="${basedir}/src" failonerror="true">
                        <arg value="/c" />
                        <arg value="ant.bat" />
                        <arg line="jar" />
                    </exec>
                </tasks>
            </configuration>
        </execution>
    </executions>
</plugin>
Chad Nouis
  • 6,861
  • 1
  • 27
  • 28
arabian_albert
  • 708
  • 1
  • 11
  • 24
  • This is a duplicate of that really: http://stackoverflow.com/questions/6352208/how-to-solve-plugin-execution-not-covered-by-lifecycle-configuration-for-sprin?rq=1 – Tunaki Feb 23 '16 at 22:24
  • They're similar but not the same, and there doesn't seem to be a resolution to that question. Perhaps I should rename this question – arabian_albert Feb 23 '16 at 22:26
  • 1
    No there is a solution. If M2E does not have the proper connector, then the only solution is to have a `pluginManagement` section, as described in the linked question. – Tunaki Feb 23 '16 at 22:27
  • Ah I see it now, however adding the `pluginManagement` tag just makes the error go away it still doesn't seem to download the maven ant plugin – arabian_albert Feb 23 '16 at 22:32

1 Answers1

2

This is a issue with M2Eclipse. You have to specify that the goal run should be executed. 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, the plugin code I'm using is this one below. I use 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>