5

Is it possible to run multiple exec-maven-plugin executions in parallel somehow?

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.

mac
  • 2,672
  • 4
  • 31
  • 43
  • Which Maven version do you use? What have you tried so far? Have you tried to run `mvn -T 2.0...`? – khmarbaise Jan 07 '15 at 08:43
  • 1
    That's for running/building multiple modules/projects in parallel. I'm not looking for that. What I need is to run multiple (java) executables in the same module/project and in the same phase in parallel. – mac Jan 07 '15 at 15:25

2 Answers2

1

Setup the project with two modules:

  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:

Example: mvn -T 4 clean install # Builds with 4 threads https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3

chevybow
  • 9,959
  • 6
  • 24
  • 39
V S
  • 11
  • 1
0

You can use a shellscript that starts the Java program on the background. This shellscript can look like:

#!/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>
Walter A
  • 19,067
  • 2
  • 23
  • 43