【问题标题】:"Plugin execution not covered by lifecycle configuration" error with maven-antrun-pluginmaven-antrun-plugin 出现“生命周期配置未涵盖插件执行”错误
【发布时间】:2016-02-23 22:21:13
【问题描述】:

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

mvn clean install

但我不断收到此错误:

生命周期配置未涵盖插件执行:org.apache.maven.plugins:maven-antrun-plugin:1.3:run (execution: build, phase: compile)

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>

【问题讨论】:

  • 这确实是一个副本:stackoverflow.com/questions/6352208/…
  • 它们相似但不相同,并且似乎没有解决该问题的方法。也许我应该重命名这个问题
  • 没有解决办法。如果 M2E 没有合适的连接器,那么唯一的解决方案是有一个 pluginManagement 部分,如链接问题中所述。
  • 啊我现在看到了,但是添加 pluginManagement 标签只会使错误消失,它似乎仍然没有下载 maven ant 插件

标签: java eclipse maven ant maven-antrun-plugin


【解决方案1】:

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

来源here

值得一提的是,我正在使用的插件代码如下。我使用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-INF\classes">
                            <fileset dir="${basedir}/target/classes" includes="**" />
                        </copy>
                    </target>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>

【讨论】:

    猜你喜欢
    • 2013-10-08
    • 2012-07-11
    • 2011-10-10
    • 2020-04-19
    • 2017-10-17
    • 2013-05-04
    • 2016-10-26
    • 1970-01-01
    • 2011-11-15
    相关资源
    最近更新 更多