编程语言
首页 > 编程语言> > java – 使用m2e的生命周期配置未涵盖的插件maven-antrun-plugin执行

java – 使用m2e的生命周期配置未涵盖的插件maven-antrun-plugin执行

作者:互联网

我知道this has been asked before,但我仍然在努力解决这个问题.当我将项目加载到eclipse时,我得到以下异常:

Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-antrun-plugin:1.7:run (execution: generate-webapp-name, phase: compile)

我的maven项目由许多模块(> 200)组成,它会导致所有模块出现问题.

我尝试忽略我的pom.xml中的运行和编译目标(在父模块中):

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

但它仍然无效.

解决方法:

您必须指定为maven-antrun-plugin(在我的情况下,运行)设置的目标应该执行.对于访问此页面的任何人,请在插件标记之前添加此代码:

<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

值得一提的是,我使用的是一个非常简单的蚂蚁代码.我正在使用的插件代码如下所示.我使用了部署阶段,但如果您愿意,可以使用另一个阶段

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

标签:java,eclipse,maven,m2e,maven-antrun-plugin
来源: https://codeday.me/bug/20190624/1282074.html