Arn*_*was 17 integration-testing maven-plugin maven exec-maven-plugin
我正在尝试使用maven执行以下方案:
这是pom.xml snip:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>launch-myApp</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-DMY_APP_HOME=/usr/home/target/local</argument>
<argument>-Djava.library.path=/usr/home/other/lib</argument>
<argument>-classpath</argument>
<classpath/>
<argument>com.foo.MyApp</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<forkMode>always</forkMode>
</configuration>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
如果我执行mvn post-integration-test,我的应用程序将作为maven进程的子进程启动,但是应用程序进程阻止maven进程执行下一阶段的集成测试.后来我发现maven exec插件中存在一个错误(或缺少功能?),因为应用程序进程阻止了maven进程.为了解决这个问题,我在一个shell脚本中封装了MyApp.java的调用,然后附加了"/ dev/null 2>&1&"以产生一个单独的后台进程.这是来自runTest.sh的剪辑(这只是一个剪辑,而不是实际剪辑):
java - DMY_APP_HOME =$2 com.foo.MyApp > /dev/null 2>&1 &
Run Code Online (Sandbox Code Playgroud)
虽然这解决了我的问题,还有其他办法吗?我错过了exec-maven-plugin的任何论据吗?
在这个线程中有一个使用 Ant 的可能解决方案:这里可能的解决方案:Maven and Exec: forking a process?
与当前解决方案相同的缺点是它也依赖于平台。您当前的解决方案只能在类 Unix/Linux 环境中运行,而基于 Ant 的解决方案正在启动 的实例cmd,该实例仅适用于 Windows。当然,使用 Maven 配置文件,人们可以创建一个配置,使用它运行的操作系统来确定启动哪个命令 shell。
| 归档时间: |
|
| 查看次数: |
7678 次 |
| 最近记录: |