"Plugin execution not covered by lifecycle configuration" maven-antrun-plugin 的错误



我正在尝试使用以下命令从 POM 文件构建项目:

mvn clean install

但是我不断收到此错误:

生命周期配置未涵盖的插件执行:org.apache.maven.plugins:maven-antrun-plugin:1.3:run (执行:构建,阶段:编译)

Eclipse似乎在其应用商店中没有Ant插件。我该如何解决这个问题?

这是我的pom.xml文件的插件部分:

<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>

这是 M2Eclipse 的一个问题。您必须指定应执行目标run。在 plugins 标记之前添加此代码:

<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>

来源在这里

值得一提的是,我使用的插件代码是下面的插件代码。我使用deploy阶段,但如果需要,您可以使用另一个阶段

<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-INFclasses">
                            <fileset dir="${basedir}/target/classes" includes="**" />
                        </copy>
                    </target>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>

相关内容

  • 没有找到相关文章

最新更新