我知道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),并且会导致所有模块出现问题。
我尝试忽略run
(在父模块中)中的compile
和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>
但它仍然不起作用。
答案 0 :(得分:4)
您必须指定为maven-antrun-plugin设置的目标(在我的情况下,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>