是否可以并行运行多个maven-exec-plugin执行?

问题描述:

是否可以以某种方式并行运行多个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. 模块1-用于插件first-dbtype-deployment 模块
  2. 用于插件second-dbtype-deployment 并且不要在这些之间建立依赖关系 然后使用多个线程执行父项目:
  1. Module 1 - for plugin first-dbtype-deployment Module
  2. 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