我尝试使用以下命令从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>
答案 0 :(得分: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>