2010-05-07 87 views
3

我有一個使用maven程序集插件從一個jar創建多個jar現在問題是我必須發佈這些jar到本地回購,就像其他maven罐由他們自己時,他們都建立行家發佈全新安裝我如何能夠在這裏做這個如何發佈多個jar文件到乾淨的安裝maven

是我的POM文件

<project> 
<parent> 
    <groupId>parent.common.bundles</groupId> 
    <version>1.0</version> 
    <artifactId>child-bundle</artifactId> 
</parent> 
<modelVersion>4.0.0</modelVersion> 
<groupId>common.dataobject</groupId> 
<artifactId>common-dataobject</artifactId> 
<packaging>jar</packaging> 
<name>common-dataobject</name> 
<version>1.0</version> 
<dependencies> 
     </dependencies> 
<build> 
    <plugins> 
    <plugin> 
    <groupId>org.jibx</groupId> 
    <artifactId>maven-jibx-plugin</artifactId> 
    <version>1.2.1</version> 
    <configuration> 
    <directory>src/main/resources/jibx_mapping</directory> 
    <includes> 
     <includes>binding.xml</includes> 
    </includes> 
    <verbose>false</verbose> 
    </configuration> 
    <executions> 
    <execution> 
     <goals> 
     <goal>bind</goal> 
     </goals> 
    </execution> 
    </executions> 
    </plugin> 
    <plugin> 
    <artifactId>maven-assembly-plugin</artifactId> 
    <executions> 
    <execution> 
     <id>make-business-assembly</id> 
     <phase>package</phase> 
     <goals> 
     <goal>single</goal> 
     </goals> 
     <configuration> 
     <appendAssemblyId>false</appendAssemblyId> 
     <finalName>flight-dto</finalName> 
     <descriptors> 
     <descriptor>src/main/assembly/car-assembly.xml</descriptor> 
     </descriptors> 
     <attach>true</attach> 
     </configuration> 
    </execution> 
    <execution> 
     <id>make-gui-assembly</id> 
     <phase>package</phase> 
     <goals> 
     <goal>single</goal> 
     </goals> 
     <configuration> 
     <appendAssemblyId>false</appendAssemblyId> 
     <finalName>app_gui</finalName> 
     <descriptors> 
     <descriptor>src/main/assembly/bike-assembly.xml</descriptor> 
     </descriptors> 
     <attach>true</attach> 
     </configuration> 
    </execution> 
    </executions> 
    </plugin> 
    </plugins> 
</build> 

    </project> 

這裏是我的彙編文件

<assembly> 
    <id>app_business</id> 
    <formats> 
    <format>jar</format> 
    </formats> 
    <baseDirectory>target</baseDirectory> 
    <includeBaseDirectory>false</includeBaseDirectory> 

    <fileSets> 
    <fileSet> 
     <directory>${project.build.outputDirectory}</directory> 
     <outputDirectory></outputDirectory> 
     <includes> 
     <include>com/dataobjects/**</include> 
     </includes> 
    </fileSet>  
    </fileSets> 
</assembly> 
+0

冠軍並不意味着包含整個文本;它們旨在對文本進行簡要的總結。 – Gumbo 2010-05-07 15:26:56

回答

2

非常感謝帕斯卡,這東西真的有效。 這裏是一個,我已經加入過多使其工作的配置..

<plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>build-helper-maven-plugin</artifactId> 
     <version>1.5</version> 
     <executions> 
      <execution> 
      <id>abc</id> 
      <phase>package</phase> 
      <goals> 
       <goal>attach-artifact</goal> 
      </goals> 
      <configuration> 
       <artifacts> 
       <artifact> 
        <file>src/main/assembly/flight-assembly.xml</file> 
        <type>xml</type> 
        <classifier>flight</classifier> 
       </artifact> 
       </artifacts> 
      </configuration> 
      </execution> 
     </executions> 
    </plugin> 
17

Build Helper Maven Plugin有一個build-helper:attach-artifact允許附加額外的工件安裝和部署。它通常像這樣使用(從Usage頁):

<project> 
    ... 
    <build> 
    <plugins> 
     <plugin> 
     <!-- add configuration for antrun or another plugin here --> 
     </plugin> 
     ... 
     <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>build-helper-maven-plugin</artifactId> 
     <version>1.5</version> 
     <executions> 
      <execution> 
      <id>attach-artifacts</id> 
      <phase>package</phase> 
      <goals> 
       <goal>attach-artifact</goal> 
      </goals> 
      <configuration> 
       <artifacts> 
       <artifact> 
        <file>some file</file> 
        <type>extension of your file </type> 
        <classifier>optional</classifier> 
       </artifact> 
       ... 
       </artifacts> 
      </configuration> 
      </execution> 
     </executions> 
     </plugin> 
    </plugins> 
    </build> 
</project> 
+1

難道你不需要告訴程序集插件做附件嗎? – bmargulies 2010-05-11 20:22:57

+2

@bmargulies這確實是自動完成的。但OP已經將'appendAssemblyId'設置爲'false',所以我假設第一個程序集在'install'或'deploy'期間被第二個程序集覆蓋,並且只有一個工件「似乎」發佈(OP沒有)提供他們,但maven日誌消息時,發生這種情況,我想他不會發布的問題,如果事情「按預期」工作)。 – 2010-05-12 04:15:36

+0

這很好地解決了我遇到的問題。我會補充一點,因爲codehaus已經關閉,這個插件的文檔和其他維護已經轉移到這裏:http://www.mojohaus.org/build-helper-maven-plugin/ – David 2017-07-25 18:31:17