Maven - 确定同一阶段不同插件目标的顺序

发布于 2025-01-08 03:12:47 字数 978 浏览 4 评论 0原文

以下代码片段是 maven-cargo 插件配置的摘录,但问题与该特定插件无关。

            <executions>
                <execution>
                    <id>start</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>deploy</goal>
                        <goal>start</goal>
                    </goals>
                </execution>
            </executions>

此配置(让我们简单地称之为插件 A)将等到 pre-integration-test 阶段,然后触发其目标 deploystart (在该订单)。

假设我有另一个插件 B,它在同一阶段相关。 有哪些选择

  1. 在 A 之前(之后)执行插件 B 的目标 ? (someStuff -> 部署 -> 开始)
  2. 在插件 A 的目标之间执行插件 B 的目标 (部署 -> someStuff -> 开始)

我认为 (1) 的答案是 此处,将目标的顺序链接到插件定义的顺序POM。但我不知道(2)。

The following snippet is an excerpt of the configuration of the maven-cargo plugin, but the question is independent from that specific plugin.

            <executions>
                <execution>
                    <id>start</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>deploy</goal>
                        <goal>start</goal>
                    </goals>
                </execution>
            </executions>

This configuration (lets simply call it plugin A) will wait till pre-integration-test phase, then fire its goals deploy and start (in that order).

Say I have another plugin B which is relevant in the same phase. What are my options to

  1. execute plugin B's goals before (after) A? (someStuff - > deploy -> start)
  2. execute plugin B's goals in-between plugin A's goals (deploy -> someStuff -> start)

I figure that the answer to (1) is here, linking the order of the goals to the order of the plugin definition in the POM. But I have no idea about (2).

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

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

发布评论

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

评论(1

离不开的别离 2025-01-15 03:12:47

你对(1)的看法是正确的。如果两个插件要在同一阶段执行,那么它们将按照 pom.xml 中声明的顺序执行。

我对(2)不是100%确定,但我认为如果没有一些技巧,这是不可能的,比如使用exec-maven-plugin,例如:

<!-- deploy -->
<plugin>
  <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven2-plugin</artifactId>
  <executions>
    <execution>
      <id>deploy</id>
      <phase>pre-integration-test</phase>
      <goals>
        <goal>deploy</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<!-- do something -->
<plugin>
  <groupId>some_other_plugin</groupId>
  <artifactId>some_other_plugin</artifactId>
  <executions>
    <execution>
      <id>someStuff</id>
      <phase>pre-integration-test</phase>
      <goals>
        <goal>some_goal</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<!-- start -->
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>start</id>
      <phase>pre-integration-test</phase>
      <goals>
        <goal>exec</goal>
      </goals>
      <configuration>
        <executable>mvn</executable>
        <commandlineArgs>org.codehaus.cargo:cargo-maven2-plugin:start -Dparam=value</commandlineArgs>
      </configuration>
    </execution>
  </executions>
</plugin>

You are right about (1). If two plugins are to be executed on the same phase, then they will be executed in the order they are declared in pom.xml.

I'm not 100% sure about the (2), but I think it's impossible without some hacks, like using exec-maven-plugin, for example:

<!-- deploy -->
<plugin>
  <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven2-plugin</artifactId>
  <executions>
    <execution>
      <id>deploy</id>
      <phase>pre-integration-test</phase>
      <goals>
        <goal>deploy</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<!-- do something -->
<plugin>
  <groupId>some_other_plugin</groupId>
  <artifactId>some_other_plugin</artifactId>
  <executions>
    <execution>
      <id>someStuff</id>
      <phase>pre-integration-test</phase>
      <goals>
        <goal>some_goal</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<!-- start -->
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>start</id>
      <phase>pre-integration-test</phase>
      <goals>
        <goal>exec</goal>
      </goals>
      <configuration>
        <executable>mvn</executable>
        <commandlineArgs>org.codehaus.cargo:cargo-maven2-plugin:start -Dparam=value</commandlineArgs>
      </configuration>
    </execution>
  </executions>
</plugin>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文