2014-01-20 48 views
0

我有一個包含2個子模塊的父項目。我想創建一個只包含項目和相關jar的包。我面臨的問題是所有源文件[java,腳本,配置]也包含在神器中,有人可以幫助如何實現這一點。 以下是我使用的描述:只有項目和從屬jar的Maven組件包

<assembly 
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> 
    <id>binaries</id> 
    <formats> 
     <format>zip</format> 
    </formats> 
    <includeBaseDirectory>false</includeBaseDirectory> 

    <moduleSets> 
     <moduleSet> 
      <useAllReactorProjects>true</useAllReactorProjects> 
      <includes> 
       <include>*:sub1</include> 
       <include>*:sub2</include> 
      </includes> 
      <binaries> 
       <outputDirectory>${artifactId}</outputDirectory> 
       <unpack>true</unpack> 
       <unpackOptions> 
        <excludes>      
         <exclude>**/resources/**</exclude> 
         <exclude>**/docs/**</exclude> 
         <exclude>**/src/**</exclude> 
        </excludes> 
       </unpackOptions> 
       <dependencySets> 
        <dependencySet> 
         <outputDirectory>${artifactId}/lib</outputDirectory> 
         <useProjectArtifact>true</useProjectArtifact> 
         <unpack>false</unpack> 
         <scope>runtime</scope> 
        </dependencySet> 
       </dependencySets> 
      </binaries> 
     </moduleSet> 
    </moduleSets> 

</assembly> 

回答

1

我會建議使用這種裝配描述的:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> 
    <id>xyz</id> 
    <formats> 
    <format>zip</format> 
    </formats> 
    <includeBaseDirectory>true</includeBaseDirectory> 
    <dependencySets> 
    <dependencySet> 
      <useProjectArtifact>false</useProjectArtifact> 
      <useTransitiveDependencies>true</useTransitiveDependencies> 
      <outputDirectory>lib</outputDirectory> 
      <unpack>false</unpack> 
      <excludes> 
      <exclude>${project.groupId}:*:*</exclude> 
      </excludes> 
     </dependencySet> 
    </dependencySets> 
    <moduleSets> 
    <moduleSet> 
     <useAllReactorProjects>true</useAllReactorProjects> 
     <binaries> 
     <outputDirectory>modules</outputDirectory> 
     <unpack>false</unpack> 
     </binaries> 
    </moduleSet> 
    </moduleSets> 
</assembly> 

根據您的描述,我會建議使用<includeBaseDirectory>true</includeBaseDirectory>因爲你所有前綴爲ouputDirectories與${artifactId}

上述描述符將創建一個zip文件,其中包含包含依賴關係的子文件夾庫和包含多模塊構建模塊的文件夾modules。 此外,我會建議創建一個separate module which is responsible for creating the archive

如果生成的壓縮包含java源文件等,那麼聽起來您正在進行包裝jar的模塊中的組裝步驟。

+0

Thanks.Your描述符做的工作。 – Lokesh

相關問題