查找 Maven 插件绑定到的默认阶段

发布于 2024-12-10 09:05:44 字数 136 浏览 3 评论 0原文

给定 pom.xml 中的 元素,如何找到它绑定到的默认阶段?

例如,我想知道 maven-war-plugin 执行在 Maven 生命周期的哪个阶段。

Given a <plugin> element in a pom.xml, how do I find the default phase that it binds to?

For example, I'd like to know which phase of the Maven lifecycle does the maven-war-plugin gets executed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黎夕旧梦 2024-12-17 09:05:44

要了解项目中实际发生的情况,最好的方法是使用 mvn help: effective-pom。它不仅显示默认值,而且还显示默认值。它显示了您当前的 pom 的实际内容。

The best way to see what's really happening in your project along those lines is with mvn help:effective-pom. It doesn't just show the defaults; it shows what actually is according to your current pom.

随梦而飞# 2024-12-17 09:05:44

我对上面的回复有疑问。

这是一个简单的 pom。它使用注释处理器插件,默认情况下绑定到 generate-sources,因为我没有指定

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.test</groupId>
    <artifactId>test-simple</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <version>2.0.5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>process</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

mvngenerate-resources 确实调用了该插件...

$ mvn install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building test-simple 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-processor-plugin:2.0.5:process (default) @ test-simple ---

但是扫描 mvnhelp: effective-pom 的输出并没有产生任何关于该插件的默认绑定的线索。

$ mvn help:effective-pom |grep generate-sources; echo $?
1

到目前为止,我发现列出默认阶段绑定的唯一方法是检查插件源。

I'm having a problem with the above-reply.

Here's a simple pom. It uses an annotation processor plugin, which is bound to generate-sources by-default, since I didn't specify a <phase>.

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.test</groupId>
    <artifactId>test-simple</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <version>2.0.5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>process</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

mvn generate-resources does indeed invoke the plugin...

$ mvn install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building test-simple 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-processor-plugin:2.0.5:process (default) @ test-simple ---

Yet scanning the output of mvn help:effective-pom doesn't yield any clue to the default binding of this plugin.

$ mvn help:effective-pom |grep generate-sources; echo $?
1

The only way I've so-far found to list default phase binding is by examining plugin source.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文