Maven maven-deploy-plugin总是上传两次 [英] Maven maven-deploy-plugin always upload twice
问题描述
在将组件发布到Nexus存储库时,我遇到了问题,Maven两次上传了文件:
I've a problem when publishing component to a Nexus repository, Maven upload the file twice:
- 第一次使用maven-deploy-plugin groupId/artifactId/version参数(这就是我想要的)
- 第二次使用pom groupId/artifactId/version参数(这是我不想要的)
我使用以下命令启动打包/部署(请参阅底部的pom.xml文件):
I launch packaging/deployment with the following command (see pom.xml file at the bottom):
mvn clean package deploy:deploy-file -e -f pom.xml
这是在处理部署阶段时maven输出控制台的代码段(前6行是正确的,但请注意最后2行是pom groupId/artifactId/version):
Here is the snippet of maven output console when handling deploy phase (the 6 first lines are correct but notice the 2 last lines with pom groupId/artifactId/version):
[INFO] --- maven-deploy-plugin:2.8.2:deploy-file (default-cli) @ assemblage-playbook ---
Uploading: http://urlRepo:8080/nexus/content/repositories/snapshots/COMPOSANTS/COMPOSANT-A/1.0/COMPOSANT-A_1.0.tar.gz
Uploaded: http://urlRepo:8080/nexus/content/repositories/snapshots/COMPOSANTS/COMPOSANT-A/1.0/COMPOSANT-A_1.0.tar.gz (2 KB at 2.7 KB/sec)
Downloading: http://urlRepo:8080/nexus/content/repositories/snapshots/COMPOSANTS/COMPOSANT-A/maven-metadata.xml
Downloaded: http://urlRepo:8080/nexus/content/repositories/snapshots/COMPOSANTS/COMPOSANT-A/maven-metadata.xml (321 B at 4.6 KB/sec)
Uploading: http://urlRepo:8080/nexus/content/repositories/snapshots/COMPOSANTS/COMPOSANT-A/maven-metadata.xml
Uploaded: http://urlRepo:8080/nexus/content/repositories/snapshots/COMPOSANTS/COMPOSANT-A/maven-metadata.xml (321 B at 1.6 KB/sec)
Downloading: http://urlRepo:8080/nexus/content/repositories/snapshots/com/com.mycompany/assemblage-playbook/1.0-SNAPSHOT/maven-metadata.xml
Uploading: http://urlRepo:8080/nexus/content/repositories/snapshots/com/com.mycompany/assemblage-playbook/1.0-SNAPSHOT/assemblage-playbook-1.0-20150209.154427
这是我的pom.xml文件:
Here is my pom.xml file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>assemblage-playbook</artifactId>
<packaging>pom</packaging>
<name>assemblage-playbook</name>
<parent>
<groupId>com.mycompany</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<descriptors>
<descriptor>assembly/playbook-assembly.xml</descriptor>
</descriptors>
<finalName>COMPOSANT-A-1.0</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>default-cli</id>
<phase>package</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<file>target/COMPOSANT-A-1.0.tar.gz</file>
<repositoryId>nexus</repositoryId>
<groupId>COMPOSANTS</groupId>
<artifactId>COMPOSANT-A</artifactId>
<version>1.0</version>
<generatePom>false</generatePom>
<packaging>tar.gz</packaging>
<url>http://urlRepo:8080/nexus/content/repositories/snapshots</url>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
有什么想法可以解决吗?
Any idee to solve it ?
感谢您的帮助.
使用命令行mvn deploy:deploy-file -e -f pom.xml
,它可以很好地工作(退出clean package
),但是我需要先打包,然后再部署...
With the command line mvn deploy:deploy-file -e -f pom.xml
, it works well (whitout clean package
), but I need to package before deploy...
推荐答案
maven-deploy-plugin上传您指定的文件,然后上传所有项目附加的工件.默认情况下,maven-assembly-plugin将输出文件附加到项目附加的工件.这样一来,您可以上传两次.
The maven-deploy-plugin uploads the file you specify then uploads the all project attached artifacts. The maven-assembly-plugin by default attaches the output file to the project attached artifacts. This makes the upload happen twice for you.
此问题是针对您的maven-assembly-plugin配置的.
The fix is to this to your maven-assembly-plugin configuration.
<attach>false</attach>
这篇关于Maven maven-deploy-plugin总是上传两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!