开发者

Maven and Exec: forking a process?

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</g开发者_如何学GoroupId>
    <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?


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>


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜