Maven and Exec: forking a process?

前端 未结 2 869
忘了有多久
忘了有多久 2020-12-06 16:37

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:



        
相关标签:
2条回答
  • 2020-12-06 17:29

    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 讨论(0)
  • 2020-12-06 17:34

    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>
    
    0 讨论(0)
提交回复
热议问题