【问题标题】:Maven - determine order of different plugin goals in the same phaseMaven - 确定同一阶段不同插件目标的顺序
【发布时间】:2012-02-22 09:18:18
【问题描述】:

下面的sn-p是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) 的答案是here,将目标的顺序与 POM 中插件定义的顺序联系起来。但我对(2)一无所知。

【问题讨论】:

    标签: maven maven-plugin


    【解决方案1】:

    关于 (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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-08
      • 2018-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-04
      • 2019-07-17
      • 2011-04-14
      相关资源
      最近更新 更多