2012-11-30 21 views
2

我想在Nexus中使用add two zips to an already published version
實質上,它們是應用程序的壓縮演示,也是同一個應用程序的擴展版本,也是壓縮的。如何讓Maven Deploy Plugin只上傳特定文件?

使用Deploy插件,我在我的pom中定義了兩個執行,每個文件一個,並將它們綁定到部署階段。下面是一個演示:

<execution> 
    <id>deploy-essential</id> 
     <phase>deploy</phase> 
     <goals> 
     <goal>deploy-file</goal> 
     </goals> 
     <configuration> 
     <file>${project.build.directory}/${project.artifactId}-${project.version}-demo.zip</file> 
     <groupId>${project.groupId}</groupId> 
     <artifactId>myproject</artifactId> 
     <version>${project.version}</version> 
     <classifier>demo</classifier> 
     <repositoryId>nexus</repositoryId> 
     <url>${targetrepository}</url> 
     <generatePom>false</generatePom> 
     </configuration> 
    </execution> 

我預想的Maven要上傳的文件,並更新tothe給予G/A/V元數據座標,當此執行上來。 不過,它會將給定的文件上載,並且它是包含完整版本的姐妹文件到給定的座標,然後再將它們再次上傳到其原始座標。

然後繼續爲第二次執行完成所有操作。下面是我的日誌摘錄:

[INFO] --- maven-deploy-plugin:2.7:deploy-file (deploy-demo) @ bundle --- 
Downloading: http://nexus/repositories/snapshots/mygroup/myproject/1.2.6-SNAPSHOT/maven-metadata.xml 
2 KB 

Downloaded: http://nexus/repositories/snapshots/mygroup/myproject/1.2.6-SNAPSHOT/maven-metadata.xml (2 KB at 4.8 KB/sec) 
Uploading: http://nexus/repositories/snapshots/mygroup/myproject/1.2.6-SNAPSHOT/myproject-1.2.6-20121130.102624-5-demo.zip 
...   
Uploaded: http://nexus/repositories/snapshots/mygroup/myproject/1.2.6-SNAPSHOT/myproject-1.2.6-20121130.102624-5-demo.zip (13032 KB at 23105.2 KB/sec) 
Downloading: http://nexus/repositories/snapshots/mygroup/myproject/maven-metadata.xml 
533 B  

Downloaded: http://nexus/repositories/snapshots/mygroup/myproject/maven-metadata.xml (533 B at 34.7 KB/sec) 
Uploading: http://nexus/repositories/snapshots/mygroup/myproject/1.2.6-SNAPSHOT/maven-metadata.xml 
2 KB  

Uploaded: http://nexus/repositories/snapshots/mygroup/myproject/1.2.6-SNAPSHOT/maven-metadata.xml (2 KB at 89.4 KB/sec) 
Uploading: http://nexus/repositories/snapshots/mygroup/myproject/maven-metadata.xml 
533 B 

Uploaded: http://nexus/repositories/snapshots/mygroup/myproject/maven-metadata.xml (533 B at 32.5 KB/sec) 
Downloading: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/maven-metadata.xml 
861 B 

Downloaded: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/maven-metadata.xml (861 B at 3.8 KB/sec) 
Uploading: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/bundle-1.2.6-20121130.102625-3-full.zip 
...   
Uploaded: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/bundle-1.2.6-20121130.102625-3-full.zip (13065 KB at 18531.7 KB/sec) 
Downloading: http://nexus/repositories/snapshots/mygroup/bundle/maven-metadata.xml 
410 B  

Downloaded: http://nexus/repositories/snapshots/mygroup/bundle/maven-metadata.xml (410 B at 8.5 KB/sec) 
Uploading: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/maven-metadata.xml 
861 B 

Uploaded: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/maven-metadata.xml (861 B at 27.1 KB/sec) 
Uploading: http://nexus/repositories/snapshots/mygroup/bundle/maven-metadata.xml 
410 B 

Uploaded: http://nexus/repositories/snapshots/mygroup/bundle/maven-metadata.xml (410 B at 5.1 KB/sec) 
Uploading: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/bundle-1.2.6-20121130.102625-3-demo.zip 
...   
Uploaded: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/bundle-1.2.6-20121130.102625-3-demo.zip (13032 KB at 13631.1 KB/sec) 
Uploading: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/maven-metadata.xml 
861 B  

Uploaded: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/maven-metadata.xml (861 B at 56.1 KB/sec) 

這不是快照大的事情,但它完全自的Nexus塊版本配置爲拒絕調動。

我不認爲這種行爲是有意的,我相信我錯過了一些東西。 我可以以某種方式讓Maven只上傳我實際配置的文件嗎?

回答

1

爲什麼不使用可以將工件附加到當前部署的程序集插件,或者使用可以簡單地將其他工件附加到構建中的build-helper-maven-plugin。在通常的構建過程中使用部署插件是錯誤的方法。

+0

你已經在這個昨天暗示。主要原因是我的項目結構,我有項目A取決於項目B和C. 這是我想要部署的A的工件,但在由B定義的組中。因此,按照現狀,連接不是一種選擇。猜猜我必須重新調整結構,儘管只有Maven解決方案是可能的。 –

1

因爲您沒有禁用默認的部署機制,所以仍在執行。你需要的東西是這樣的:

 <plugin> 
      <artifactId>maven-deploy-plugin</artifactId> 
      <executions> 
       <!-- disable standard deploy --> 
       <execution> 
        <id>default-deploy</id> 
        <phase>none</phase> 
       </execution> 
       <execution> 
        <id>deployEssential</id> 
        <phase>deploy</phase> 
        ... 
       </execution> 
      </executions> 
     </plugin> 
0

最少的頭痛是wagon-maven-plugin爲我做相同的:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>wagon-maven-plugin</artifactId> 
    <version>1.0</version> 
    <executions> 
     <execution> 
      <id>deploy-release</id> 
      <phase>deploy</phase> 
      <goals> 
       <goal>upload</goal> 
      </goals> 
      <configuration> 
       <serverId>nexus</serverId> 
       <url>${targetrepository}</url> 
       <fromDir>${project.build.directory}</fromDir> 
       <toDir>${project.version}</toDir> 
       <includes> 
        ${project.artifactId}-${project.version}-demo.zip 
       </includes> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 
相關問題