2012-10-29 25 views
1

我有multimudule項目。模塊之一是組裝,具有描述符將核心(庫)和示例放在一個zip中。如何重命名結果程序集以在.m2中安裝

<assembly> 
<id>assembly</id> 
<formats> 
    <format>zip</format> 
    <format>dir</format> 
</formats> 
<includeBaseDirectory>false</includeBaseDirectory> 

<dependencySets> 
    <dependencySet> 
     <useTransitiveDependencies>false</useTransitiveDependencies> 
     <outputDirectory>/</outputDirectory> 
    </dependencySet> 
</dependencySets> 

這是我的assemly,這是插件配置

<plugins> 
     <plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <configuration> 
       <descriptors> 
        <descriptor>assembly.xml</descriptor> 
       </descriptors> 
      </configuration> 
      <executions> 
       <execution> 
        <id>package-assembly</id> 
        <phase>package</phase> 
        <goals> 
         <goal>single</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 

我已經導致安裝在我的文件夾中的.m2精細拉鍊,但名稱是裝配中共-... 。我需要將它重命名爲my-project,它可以在插件中使用2行完成:

<finalName>my-project</finalName> 
<appendAssemblyId>false</appendAssemblyId> 

它在targ et文件夾(我可以看到my-project.zip),但是現在生成的zip文件未安裝在我的.m2文件夾中。所以,問題是如何讓它安裝在我的.m2文件夾中? (從父項目與運行:全新安裝)

找到輸出:

[INFO] Building Assebly 
[INFO] task-segment: [clean, install] 
[INFO] ------------------------------------------------------------------------ 
[INFO] [clean:clean {execution: default-clean}] 
[INFO] Deleting directory /home/dmitry/mbus/trunk/assembly/target 
[INFO] [site:attach-descriptor {execution: default-attach-descriptor}] 
[INFO] Preparing source:jar 
[WARNING] Removing: jar from forked lifecycle, to prevent recursive invocation. 
[INFO] No goals needed for project - skipping 
[INFO] [source:jar {execution: default}] 
[INFO] [assembly:single {execution: package-assembly}] 
[INFO] Reading assembly descriptor: assembly.xml 
[INFO] Processing DependencySet (output=/) 
[WARNING] Cannot include project artifact: com.comcast.xcal.mbus:assembly:pom:CCP-LATEST-SNAPSHOT; it doesn't have an associated file or directory. 
[INFO] Building zip: /home/dmitry/mbus/trunk/assembly/target/my-project.zip 
[WARNING] Configuration options: 'appendAssemblyId' is set to false, and 'classifier' is missing. 
Instead of attaching the assembly file: /home/dmitry/mbus/trunk/assembly/target/my-project.zip, it will become the file for main project artifact. 
NOTE: If multiple descriptors or descriptor-formats are provided for this project, the value of this file will be non-deterministic! 
[INFO] Processing DependencySet (output=/) 
[INFO] Copying files to /home/dmitry/mbus/trunk/assembly/target/my-project.dir 
[WARNING] Assembly file: /home/dmitry/mbus/trunk/assembly/target/my-project.dir is not a regular file (it may be a directory). It cannot be attached to the project build for installation or deployment. 
[INFO] [install:install {execution: default-install}] 
[INFO] Installing /home/dmitry/mbus/trunk/assembly/pom.xml to /home/dmitry/.m2/repository/com/mbus/assembly/CCP-LATEST-SNAPSHOT/assembly-CCP-LATEST-SNAPSHOT.pom 
[INFO] [javadoc:jar {execution: default}] 
[INFO] Not executing Javadoc as the project is not a Java classpath-capable package 
[INFO] 
[INFO] 
+0

您可能想再次查看它。這是通過''設置程序集插件來控制的,默認情況下它是'true'。所以zip檔案應該在你的倉庫中。 –

+0

設置 true沒有幫助,我可以在目標中看到zip,但它不是回購。 – user1255246

+0

顯示你的Maven執行的日誌文件。 –

回答

0

發表在倉庫的.m2的名字始終是${module.artifactId}-${module.version}.${module.extension}finalName設置和封裝在target文件夾重命名正確。

我發現了兩個方法來改變這種狀況:

  1. 不是一個真正的解決方案:改變的artifactId(但它是解決方案,我最終選擇了我的項目)

  2. 坐落在一個id組件XML:

    組裝

    /resources.xml中 - ><id> =期望的後綴(例如<id>myappid</id>

    在pom.xml中行家組裝-插件生成部分,設置appendAssemblyId爲true

    其結果將是:目標文件夾中

    • 文件名= ${artifactId}-${version}-${assemblyId}.zip
    • 文件中的.m2回購夾=與目標相同