2012-04-23 43 views
1

我有一個多模塊maven項目,以及許多代碼模塊,它們構建標準jar文件,我有一個模塊構建一個測試用具作爲zip文件使用maven-assembly -plugin和另一個使用rpm-maven-plugin構建應用程序rpm的模塊。我想在rpm中包含測試工具zip文件。maven包括從另一個模塊彙編到rpm

目前我做的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中的模塊順序來確保首先構建測試工具,這似乎有點弱,因爲依賴相對路徑來包含測試工具在繪圖中......必須有更好的方法。

回答

2

最好的事情是首先不使用訪問其他模塊(../target/等)的相對路徑。在rpm模塊中更好地使用依賴關係。例如,將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配置等之後,執行以下操作:

<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> 

我不是100%肯定這對包括(確切順序的artifactId:分類:類型:版本)?

+0

將測試工具添加爲依賴項(即使對於分類器和類型)仍然會導致它及其傳遞依賴項包含在rpm lib目錄中。排除lib目錄映射中的測試工具只是排除了測試工具,但仍然保留其傳遞依賴性 - 但我認爲這是正確的方向 – 2012-04-24 09:39:00

+0

在依賴性區域添加排除。這應該夠了吧。 – khmarbaise 2012-04-24 10:15:04

相關問題