我刚刚开始使用maven。所以请忽略,如果这是太基本的问题。
这是我的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.abc</groupId>
<artifactId>debug</artifactId>
<packaging>war</packaging>
<name>Debug</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<warSourceExcludes>abc/**</warSourceExcludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>default</id>
<phase>generate-sources</phase>
<configuration>
<tasks>
<!-- Some work -->
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>post.package</id>
<phase>post-package</phase>
<configuration>
<tasks>
<echo>This is not running</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
以上运行成功,war文件在目标/类中创建,但post-package
阶段未运行。有什么问题?这是因为我没有定义package
阶段吗?如果是这样,为什么包装要完成?
答案 0 :(得分:2)
这是因为Maven中没有post-package
这样的阶段:
Here是对Maven Lifecycle及其流程的引用。
如果您想在package
阶段后执行特定任务,您可以选择
<execution>
<id>post-package</id>
<phase>pre-integration-test</phase>
<configuration>
<tasks>
<echo>This would run during pre-integration-test phase</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>