2016-05-05 8 views
0

統合テストの実行が終了したときにプロセスを起動してそのプロセスを終了することができるかどうか教えていただけますか?maven ant runプラグイン - 生成されたプロセスを殺す

私は現在、アンティルランプラグインを使用してgrunt接続サーバーを開始しています。私はtomcatにレストアプリケーションをデプロイするために貨物を使用しています。これにより、レストサービスを呼び出すランニングアングルWebアプリケーションに対する統合テストが可能になります。

私はそれがほしいと思うものがほとんどありますが、ビルドが完了したら、私はkeep keep aliveをtrueに設定しているので、gruntサーバーはまだ実行されています。

私のビルドが終了したら、どういうわけかサーバーのプロセスを強制終了したいと考えています。

+0

何か:http://stackoverflow.com/questions/35453479/gracefully-stopping-a-java-process-started-by -maven-antrun-plugin? – Tunaki

+0

おそらく私はJavaプロセスを生成していませんが、実際にはcmdまたはシェルを生成し、それを使ってサーバを起動させるスクリプトを起動します。このコマンドを使用してコマンドプロンプトを終了することはできますか? – berimbolo

答えて

0

最後の部分として私はこれをやり直しました。マルチモジュールプロジェクトをビルドし、ビルドがmavenで動作するように、フロントエンドとJavaバックエンドに対して統合テストを実行する必要がありました。

生まれたノードサーバーを強制終了するために最後に行うことは、ant runプラグインを使用してそれを強制終了することです(単純です!)。

とにかく、これは将来的に他の誰かを助けるかもしれないhopefull:このような

<plugin> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <version>1.7</version> 
      <executions> 
       <execution> 
        <id>Run grunt integration-test task in pre-integration-test phase</id> 
        <phase>pre-integration-test</phase> 
        <configuration> 
         <target name="starting"> 
          <echo> 

          </echo> 
          <exec executable="cmd" spawn="true" dir="${project.basedir}" 
           osfamily="windows"> 
           <arg line="/c grunt int-test --no-color > grunt.status " /> 
          </exec> 
          <exec executable="bash" spawn="true" dir="${project.basedir}" 
           osfamily="unix"> 
           <arg line="grunt int-test --no-color > grunt.status" /> 
          </exec> 
         </target> 
        </configuration> 
        <goals> 
         <goal>run</goal> 
        </goals> 
       </execution>        
       <execution> 
        <id>Kill NodeServer in post-integration-test phase</id> 
        <phase>post-integration-test</phase> 
        <configuration> 
         <target name="ending"> 
          <echo> 

          </echo> 
          <exec executable="cmd" spawn="true" dir="${project.basedir}" 
           osfamily="windows"> 
           <arg line="/c Taskkill /IM node.exe /F " /> 
          </exec> 
          <exec executable="bash" spawn="true" dir="${project.basedir}" 
           osfamily="unix"> 
           <arg line="kill -9 $(ps aux | grep '\snode\s' | awk '{print $2}')" /> 
          </exec> 
         </target> 
        </configuration> 
        <goals> 
         <goal>run</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
関連する問題