Maven和Exec:分配流程?

Dan*_*ton 14 exec maven

我正在尝试使用Maven在运行某些集成测试之前启动应用程序.我在Windows上.我的Maven插件配置如下所示:

<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>
Run Code Online (Sandbox Code Playgroud)

我的批处理文件如下所示:

start myApplication.exe
Run Code Online (Sandbox Code Playgroud)

在隔离运行时,批处理文件会生成一个单独的窗口来运行应用程序并立即返回控制.

但是,从Maven运行时,构建会在继续之前等待单独窗口中的进程完成.这在某种程度上打败了集成测试阶段......

我有什么想法可以在Maven中启动一个真正独立的过程,以便让构建继续与它一起继续吗?

Dan*_*ton 12

为了记录,一个相当hackish的解决方案是使用maven-antrun-plugin调用Ant,它能够产生单独的进程:

<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>
Run Code Online (Sandbox Code Playgroud)