有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java maven后打包阶段未运行

我刚从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阶段吗?那么,为什么要完成包装呢


共 (1) 个答案

  1. # 1 楼答案

    这是因为Maven中没有post-package这样的阶段:

    Here是对Maven生命周期及其过程的引用

    如果要在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>