14

I'm trying to use Maven to start an application prior to running some integration tests on it. I'm on Windows. My Maven plugin configuration looks like this:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1</version>
    <executions>
        <execution>
            <id>start-my-application</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>start_application.bat</executable>
                <workingDirectory>./path/to/application</workingDirectory>
            </configuration>
        </execution>
    <executions>
<plugin>

and my batch file looks like this:

start myApplication.exe

When run in isolation, the batch file spawns a separate window to run the application and immediately returns control.

However, when run from Maven, the build waits for the process in the separate window to finish before continuing. This somewhat defeats the point of the integration testing phase...

Any ideas how I can start a truly separate process in Maven to allow the build to continue alongside it?

Dan Vinton
  • 26,401
  • 9
  • 37
  • 79

2 Answers2

12

For the record, a rather hackish solution is to use maven-antrun-plugin to call Ant, which is capable of spawning separate processes:

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
            <phase>pre-integration-test</phase>
            <configuration>
                <target>
                    <exec executable="cmd"
                          dir="./path/to/application"
                          spawn="true">
                        <arg value="/c"/>
                        <arg value="start_application.bat"/>
                    </exec>
                </target>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
       </execution>
   </executions>
</plugin>
Dan Vinton
  • 26,401
  • 9
  • 37
  • 79
1

Try this:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1</version>
    <executions>
        <execution>
            <id>start-my-application</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>call</executable>
                <arguments>
                    <argument>start_application.bat</argument>
                </arguments>
                <workingDirectory>./path/to/application</workingDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>
javamonkey79
  • 17,443
  • 36
  • 114
  • 172