是否可以以某种方式并行运行多个 exec-maven-plugin 执行?
我们希望为 DAL 集成测试部署不同的数据库类型,虽然很明显可以按顺序执行此操作,但这是对时间的巨大浪费。
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>first-dbtype-deployment</id>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.example.DeployDBTypeOne</mainClass>
</configuration>
</execution>
<execution>
<id>second-dbtype-deployment</id>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.example.DeployDBTypeTwo</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</build>
实际部署的相应配置当然更复杂,但我认为这与所涉及的特定问题无关。
最佳答案
您可以使用在后台启动 Java 程序的 shellscript。
这个 shellscript 看起来像:
#!/bin/bash
echo Starting dbtype-deployment $* on the background
java $* >/dev/null 2>&1 &
在您的 pom.xml 中,您可以使用 com.example.DeployDBTypeTwo 作为参数。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>dbtype-deployment-x</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>startjava.sh</executable>
<workingDirectory>${project.build.directory}/youKnowBest</workingDirectory>
<arguments><argument>com.example.DeployDBTypeTwo</argument></arguments>
</configuration>
</plugin>
关于maven - 是否可以并行运行多个 maven-exec-plugin 执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27804862/