3

開発したアプリケーションがあり、ビルド プロセスを簡単にしようとしています。親の POM ファイルは次のようになります。

<parent>
    <groupId>com.shc.obu.ca</groupId>
    <artifactId>shcobuca-pom</artifactId>
    <version>1.1.0</version>   </parent>

  <groupId>com.shc.obu.ca.osol</groupId> <artifactId>apps-pom</artifactId>   <version>${currVersion}</version>   <packaging>pom</packaging>   <name>Outlet Apps</name>

  <scm>
    <connection>scm:svn:https://ushofsvpsvn2.intra.searshc.com/svn/outlet/outlet/trunk/apps</connection>
    <developerConnection>scm:svn:https://ushofsvpsvn2.intra.searshc.com/svn/outlet/outlet/trunk/apps</developerConnection> </scm>
    <profiles>
    <profile> <id>www</id>
      <activation> <activeByDefault>true</activeByDefault> </activation>
      <modules>
        <module>www</module>
        <module>modules</module> 
      </modules>
    </profile>
    <profile> 
      <id>mts</id>
      <activation> <activeByDefault>true</activeByDefault> </activation>
      <modules>
        <module>mts</module> 
        <module>modules</module> 
      </modules>
    </profile>
    <profile> <id>search</id>
      <activation> <activeByDefault>true</activeByDefault> </activation>
      <modules>
        <module>modules</module> 
        <module>search</module> 
      </modules>
    </profile>   </profiles>

  <repositories>
    <repository>
      <id>obu.ca.repo.release</id>
      <snapshots><enabled>false</enabled></snapshots>
      <url>http://maven.cal.intra.sears.com/release</url>
    </repository>
    <repository>
      <id>obu.ca.repo.snapshot</id>
      <releases><enabled>false</enabled></releases>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>interval:5</updatePolicy>
      </snapshots>
      <url>http://maven.cal.intra.sears.com/snapshot</url>
    </repository>   </repositories>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <env>trunk</env>
    <currVersion>1.2.0</currVersion>   </properties>   </project>

このファイルは、基本的に独立した子プロジェクトである 3 つのプロファイルを持っていることを示しています。以下のように、このファイルに貨物プラグインを追加しています。

<build>
  <plugins>
      <plugin>
        <groupId>org.codehaus.cargo</groupId>
        <artifactId>cargo-maven2-plugin</artifactId>
        <version>1.0</version>
        <configuration>
          <container>
              <containerId>tomcat6x</containerId>
              <home>
                  C:\tools\apache-tomcat-6.0.26
              </home>
          </container>
          <configuration>
              <properties>
                  <cargo.servlet.port>
                      8082
                  </cargo.servlet.port>
                  <cargo.jvmargs>
                      "-Xdebug" "-Xrunjdwp:transport=dt_socket,address=4646,server=y,suspend=n"
                  </cargo.jvmargs>
              </properties>
          </configuration>     
        </configuration>  
      </plugin>
  </plugins>
  </build>

しかし、「mvn cargo:start」を実行すると、Tomcat インスタンスは正常に動作しますが、子アプリはデプロイされません。最初の子アプリケーション (www) (www-webapp-1.2.0.war という war ファイルを生成する) を自動デプロイする方法はありますか?

更新: Pascal に感謝します。以下のようにビルドタグを変更してみました:

<build>
  <plugins>
      <plugin>
        <groupId>org.codehaus.cargo</groupId>
        <artifactId>cargo-maven2-plugin</artifactId>
        <version>1.0</version>
        <configuration>
          <container>
              <containerId>tomcat6x</containerId>
              <home>
                  C:\tools\apache-tomcat-6.0.26
              </home>
          </container>
          <configuration>
              <properties>
                  <cargo.servlet.port>
                      8082
                  </cargo.servlet.port>
                  <cargo.jvmargs>
                      "-Xdebug" "-Xrunjdwp:transport=dt_socket,address=4646,server=y,suspend=n"
                  </cargo.jvmargs>
              </properties>              
              <deployables> 
                <deployable> 
                  <groupId>com.shc.obu.ca.osol</groupId> 
                  <artifactId>www-webapp-1.2.0</artifactId> 
                  <type>war</type> 
                  <properties> 
                    <context>acontext</context> 
                  </properties> 
                </deployable> 
              </deployables>               
          </configuration>    
        </configuration>  
      </plugin>
  </plugins>
  </build>

しかし、まだ機能していません。以下のようにビルドエラーが発生します。

アーティファクト [com.shc.obu.ca.osol:www-webapp-1.2.0:war] はプロジェクトの依存関係ではありません。「www-webapp」と「www」もアーティファクト ID として試しましたが、エラーは同じままでした。

同じものを依存関係タグに追加すると、次のような循環参照エラーが発生します。「リアクター内のプロジェクトには循環参照が含まれています」

4

2 に答える 2

2

要素www内にデプロイするモジュールとしてモジュールをリストする必要があります。Maven2プラグインリファレンスガイド<deployable>から:

デプロイ可能なものが指定されておらず、プロジェクトのパッケージが war、ear、または ejb であり、デプロイヤーが指定されていない場合、生成されたアーティファクトは、デプロイするデプロイ可能なもののリストに自動的に追加されます。

プロジェクトpackaingのタイプpomは であるため、デプロイの候補ではなく、何もデプロイされません。

次に例を示します。

  <plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.0</version>
    <configuration>
      <container>
        <containerId>tomcat6x</containerId>
        <home>C:\tools\apache-tomcat-6.0.26</home>
      </container>
      <configuration>
        <properties>
          <cargo.servlet.port>8082</cargo.servlet.port>
          <cargo.jvmargs>
              "-Xdebug" "-Xrunjdwp:transport=dt_socket,address=4646,server=y,suspend=n"
          </cargo.jvmargs>
        </properties>
        <deployables>
          <!-- application to deploy -->
          <deployable>
            <groupId>com.acme</groupId>
            <artifactId>mywebapp</artifactId>
            <type>war</type>
            <properties>
              <context>acontext</context>
            </properties>
          </deployable>
        </deployables>
      </configuration>     
    </configuration>  
  </plugin>

アップデート:

(...)以下のようにビルドエラーが発生しています

アーティファクト [com.shc.obu.ca.osol:www-webapp-1.2.0:war] はプロジェクトの依存関係ではありません。「www-webapp」と「www」もアーティファクト ID として試しましたが、エラーは同じままでした。

私はそれを忘れていましたがdeployable、Cargo は、Cargo が開始されたプロジェクトの依存関係になることを期待しているようです。

同じものを依存関係タグに追加すると、次のような循環参照エラーが発生します。「リアクター内のプロジェクトには循環参照が含まれています」

これは正常です。アーティファクトは、特定のプロジェクトのサブモジュールおよび依存関係にすることはできません。または、循環依存関係を取得することはできません (依存関係、ニワトリと卵の問題であるモジュールを構築するには、依存関係が必要です)。

私の提案は、貨物構成をwwwモジュールに移動するか、機能テスト用の専用モジュールを作成し (これは通常私が行うことです)、wwwこのモジュールの依存関係として宣言することです。

于 2010-07-05T14:15:29.773 に答える