Can multiple maven-exec-plugin runs be run in parallel?
Is it possible to run multiple exec-maven-plugin executions in parallel?
We want to have different types of databases deployed to test DAL integration, and while it is obviously possible to do this consistently, it is 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 corresponding configuration for the actual deployment is of course more complicated, but I think it doesn't matter for the specific question posed.
+4
source to share
2 answers
You can use shellscript, which runs a Java program in the background. This shellscript might look like this:
#!/bin/bash
echo Starting dbtype-deployment $* on the background
java $* >/dev/null 2>&1 &
In your pom.xml, you can use com.example.DeployDBTypeTwo as an argument.
<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>
0
source to share
Set up a project with two modules:
- Module 1 - for plugin first-dbtype-deploy Module
- for plugin second-dbtype-deploy and don't create dependencies between them and then execute parent project with multiple threads:
Example: mvn -T 4 clean install # Build with 4 threads https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3
0
source to share