是否可以并行运行多个maven-exec-plugin执行? [英] Is it possible to run multiple maven-exec-plugin executions in parallel?
问题描述
是否可以以某种方式并行运行多个exec-maven-plugin执行?
Is it possible to run multiple exec-maven-plugin executions in parallel somehow?
我们希望为DAL集成测试部署不同的数据库类型,并且虽然有可能按顺序执行此操作,但这会浪费大量时间.
We want to have different database types deployed for DAL integration testing, and while it's obviously possible to do this in sequence, it's a huge waste of time.
<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>
用于实际部署的各个配置当然要复杂得多,但是我认为这与所要解决的特定问题无关.
The respective configuration for the actual deployment are of course more complicated, but I think that's irrelevant for the particular question at stake.
推荐答案
使用两个模块设置项目:
Setup the project with two modules:
- 模块1-用于插件first-dbtype-deployment 模块
- 用于插件second-dbtype-deployment 并且不要在这些之间建立依赖关系 然后使用多个线程执行父项目:
- Module 1 - for plugin first-dbtype-deployment Module
- for plugin second-dbtype-deployment and do not create dependencies between these and then execute parent project with multiple threads:
示例: mvn -T 4 clean install#建立4个线程 https://cwiki.apache.org/confluence/display/MAVEN/Parallel + builds + in + Maven + 3
Example: mvn -T 4 clean install # Builds with 4 threads https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3
这篇关于是否可以并行运行多个maven-exec-plugin执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!