maven を使用して次のシナリオを実行しようとしています:
- pre-integration-phase : メイン クラスを使用して Java ベースのアプリケーションを開始します (exec-maven-plugin を使用)。
- integration-phase : 統合テスト ケースを実行します (maven-failsafe-plugin を使用)
- post-integration-phase: アプリケーションを正常に停止します (exec-maven-plugin を使用)
ここに pom.xml スニップがあります:
<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>
mvn post-integration-test を実行すると、アプリケーションは maven プロセスの子プロセスとして開始されますが、アプリケーション プロセスは maven プロセスが次のフェーズで行われる統合テストの実行をブロックしています。後で、アプリケーション プロセスが maven プロセスをブロックするため、maven exec プラグインにバグ (または機能の欠落?)があることがわかりました。この問題に対処するために、MyApp.java の呼び出しをシェル スクリプトにカプセル化し、「/dev/null 2>&1 &」を追加して別のバックグラウンド プロセスを生成しました。runTest.sh の抜粋 (これは単なる抜粋であり、実際のものではありません) は次のとおりです。
java - DMY_APP_HOME =$2 com.foo.MyApp > /dev/null 2>&1 &
これで問題は解決しましたが、他に方法はありますか? exec-maven-plugin の引数がありませんか?