1

標準のjarファイルを構築する多くのコードモジュールとともに、マルチモジュールのmavenプロジェクトがあり、maven-assembly-pluginを使用してzipファイルとしてテストハーネスを構築する1つのモジュールと、使用してアプリケーションrpmを構築する別のモジュールがあります。 rpm-maven-プラグイン。rpm 内にテスト ハーネスの zip ファイルを含めたいと考えています。

現在、rpmモジュールで次のことを行っています。

<dependencies>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>appn</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>test-harness</artifactId>
        <version>${project.version}</version>
    </dependency>
</dependencies>

<build>
    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>rpm-maven-plugin</artifactId>
    <configuration>
    :
    <mapping>
        <directory>/opt/app/installed/${rpmSoftwareName}-${project.version}/utils</directory>
        <username>${rpmUsername}</username>
        <groupname>${rpmGroupname}</groupname>
        <filemode>0755</filemode>
        <sources>
            <source>
                <location>${project.build.directory}/../../test-harness/target/test-harness-${project.version}-dist.zip</location>
            </source>
        </sources>
    </mapping>
    <mapping>
        <directory>/opt/app/installed/${rpmSoftwareName}-${project.version}/lib</directory>
        <username>${rpmUsername}</username>
        <groupname>${rpmGroupname}</groupname>
        <filemode>0755</filemode>
        <dependency />
    </mapping>

問題は、rpm の lib ディレクトリにテスト ハーネスとその推移的な依存関係が含まれていることです。lib マッピングからテスト ハーネスを除外すると、テスト ハーネスは取得されませんが、推移的な依存関係は取得されます。依存関係としてテスト ハーネスを削除すると、親 pom のモジュールの順序に依存して、テスト ハーネスが最初にビルドされるようにする必要があります。マッピングで...もっと良い方法があるはずです。

4

1 に答える 1

2

最善の方法は、まず、他のモジュールにアクセスする相対パス (../target/ など) を使用しないことです。rpm-module で依存関係を使用することをお勧めします。たとえば、適切な分類子を持つ依存関係として zip ファイルを定義します。

<dependencies>
  <dependency>
     <groupId>project.com.domain</groupId>
     <artifactId>test-harness</artifactId>
     <version>${project.version}</version>
     <classifier>dist</classifier>
     <type>zip</type>
  </dependency>
</dependencies>

次のように依存関係を rpm-configuration に追加するだけです。

<mapping>
  <directory>/usr/local/lib</directory>
  <filemode>750</filemode>
  <username>dumper</username>
  <groupname>dumpgroup</groupname>
  <dependency>
    <includes>
      <include>...:test-harness:dist:zip:${project.version}</include>
      <include>...</include>
    </includes>
    <excludes>
      <exclude>...</exclude>
    </excludes>
  </dependency>
</mapping>

インクルードの正確な順序 (artifactId:classifier:type:version?) がどれであるかは 100% わかりません。

于 2012-04-24T05:32:55.740 に答える