Maven插件附加执行

问题描述 投票:0回答:1

执行Maven-Maven-Plugin

执行myplugin(取决于步骤1)

    再次执行Maven-Maven-Asembly-Plugin(取决于步骤2)
  1. 再次执行myplugin(取决于步骤3)
  2. 当我顺序定义插件时(与上述相同的顺序)时,执行顺序:
  3. 执行Maven-Maven-Plugin
  4. 再次执行Maven-Maven-Plugin
执行myplugin

再次执行myplugin

我的解决方案是将自己插件中的所有执行组合在一起以控制确切的顺序,但我认为这不是最好的方法。谢谢!
  1. 您绝对必须在相同的阶段运行插件?您不能使用其他相关阶段吗?如今,Maven有很多阶段:)例如“准备包” vs.“包装”。 我可能会尝试为这样的插件定义多个执行(BWT这不是现实情况):
  2. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.2.1</version> <executions> <execution> <id>assembly1</id> <goals> <goal>assembly</goal> </goals> <phase>prepare-package</phase> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </execution> <execution> <id>assembly2</id> <goals> <goal>assembly</goal> </goals> <phase>package</phase> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </execution> </executions> </plugin>
  3. 确保它是否适用于您所需的订单。可能值得一试。
您可以使用

seq-maven-plugin

为此。
maven-plugin
1个回答
2
投票
元素,该元素指向插件坐标(可选地使用执行ID,在这种情况下,从那里获取配置)。您还可以在“步骤元素”中配置Incution内联。

<plugin> <groupId>io.github.qudtlib</groupId> <artifactId>seq-maven-plugin</artifactId> <version>1.0.0</version> <executions> <execution> <id>run-sequence</id> <phase>prepare-package</phase> <goals> <goal>run</goal> </goals> <configuration> <label>My Sequence</label> <steps> <step> <pluginCoordinates>assembly:assembly@first<pluginCoordinates> </step> <step> <pluginCoordinates>myplugin:mygoal@firstExec<pluginCoordinates> </step> <step> <pluginCoordinates>assembly:assembly@second<pluginCoordinates> </step> <step> <pluginCoordinates>myplugin:mygoal@secondExec<pluginCoordinates> </step> </steps> </configuration> </execution> </executions> </plugin> <!-- executions of the plugins you want, using <phase> none </phase>. Exemplified with assembly plugin, the myplugin:mygoal@firstExec and myplugin:mygoal@secondExec config is omitted here <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.2.1</version> <executions> <execution> <id>first</id> <goals> <goal>assembly</goal> </goals> <phase>none</phase> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </execution> <execution> <id>second</id> <goals> <goal>assembly</goal> </goals> <phase>none</phase> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </execution> </executions> </plugin>

	

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.