2016-04-11 5 views
1

実行プロファイル上にtomcat7-maven-pluginを使用してアプリケーションを実行するmavenビルドがあります。 私はtomcatの実行と並行してjar(例えばmaven-exec-pluginを使って)を実行したいと思います。この瓶は私が地元の開発に使うLDAPサービスです。mavenビルドでのtomcatとjarの並列実行

これまでのところ、私は別のMavenの実行(他のPOM)で、このjarファイルを実行するエーブルされてきた:私はMavenの依存性 - プラグインの同じポンポンでこれを追加した場合

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <version>1.4.0</version> 
    <executions> 
     <execution> 
      <phase>run</phase> 
      <goals> 
       <goal>java</goal> 
      </goals> 
      <configuration> 
       <mainClass>x.y.z.ldap.LdapServerRunner</mainClass> 
       <arguments> 
        <argument>localhost</argument> 
        <argument>50000</argument> 
        <argument>src/main/resources/ldap-dev.ldif</argument> 
       </arguments> 
       <includePluginDependencies>true</includePluginDependencies> 
       <includeProjectDependencies>true</includeProjectDependencies> 
      </configuration> 
     </execution> 
    </executions> 
    <dependencies> 
     <dependency> 
      <artifactId>j</artifactId> 
      <groupId>x.y.z</groupId> 
      <version>x.x.x-SNAPSHOT</version> 
     </dependency> 
    </dependencies> 
</plugin> 

、Mavenの待ち時間tomcatの実行を開始する前にメインが終了するようにします。 私のjar(x.y.z.ldap.LdapServerRunner)を、ローカルのTomcat実行時と同じ時間に実行できるかどうかを知りたいと思います。

+1

あなたがしようとしたことがあり[パラレルビルドin Maven 3](https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3)? –

+0

いいえ、私は見てみましょう。ありがとう。 – Akah

答えて

0

私は戦術を変更しました: 別々のjar実行を並行して実行することを絶対に試みるのではなく(関連するすべての問題を処理するために)、私はjarをwar(特定のmavenプロファイル):

  • 私は私のサーバーの開始を書かれ、に停止しましたjavax.servlet.ServletContextListenerを実装する単純なクラスを作成しましたがをcontextInitializedと方法をcontextDestroyed。

  • 私は私のプロジェクト(SRC /メイン/ webappの/ WEB-INF/web.xmlの)単純なweb.xmlファイルを入れている
  • :私は私のLDAP戦争を含めました

    <listener> 
        <listener-class>x.y.z.EmbeddedLdapListener</listener-class> 
    </listener> 
    
  • アプリケーションの戦争:

    <plugin> 
         <groupId>org.apache.tomcat.maven</groupId> 
         <artifactId>tomcat7-maven-plugin</artifactId> 
         <webapps> 
          <webapp> 
          <groupId>x.y.z</groupId> 
          <artifactId>myapp</artifactId> 
          <version>1.0.0-SNAPSHOT</version> 
          <type>war</type> 
          <asWebapp>true</asWebapp> 
          <contextPath>/myapp</contextPath> 
         </webapp> 
         <webapp> 
         <groupId>x.y.z</groupId> 
         <artifactId>myldapembedded</artifactId> 
         <version>1.0.0-SNAPSHOT</version> 
         <type>war</type> 
         <asWebapp>true</asWebapp> 
         <contextPath>/ldap</contextPath> 
         </webapp> 
         ... 
    

PS:プロパティの一部(ポート、サーバーなど)のために、私は、システムのプロパティを使用しました。

  1. あなたはtomcat7-のmaven-pluginの中でそれらを定義することができます。その後、

     <plugin> 
         <groupId>org.apache.tomcat.maven</groupId> 
         <artifactId>tomcat7-maven-plugin</artifactId> 
         ... 
         <configuration> 
          <systemProperties> 
          <myproperty>myvalue</myproperty> 
    
  2. そして、あなたのListernerでそれを使用します。

     System.getProperty("myproperty", mydefaultValue) 
    
関連する問題