gpt4 book ai didi

Maven maven-deploy-plugin 总是上传两次

转载 作者:行者123 更新时间:2023-12-03 08:29:42 28 4
gpt4 key购买 nike

将组件发布到 Nexus 存储库时出现问题,Maven 上传文件两次:

  • 第一次使用 maven-deploy-plugin groupId/artifactId/version 参数(这就是我想要的)
  • 第二次使用 pom groupId/artifactId/version 参数(这是我不想要的)

  • 我使用以下命令启动打包/部署(请参阅底部的 pom.xml 文件):
    mvn clean package deploy:deploy-file -e -f pom.xml
    这是处理部署阶段时 maven 输出控制台的片段(前 6 行是正确的,但请注意带有 pom groupId/artifactId/version 的最后 2 行):

    [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 文件:

    <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>

    任何想法来解决它?

    谢谢你的帮助。

    [编辑]

    使用命令行 mvn deploy:deploy-file -e -f pom.xml ,它运行良好(没有 clean package),但我需要在部署前打包...

    最佳答案

    maven-deploy-plugin 上传您指定的文件,然后上传所有项目附加的 Artifact 。 maven-assembly-plugin 默认将输出文件附加到项目附加的 Artifact 。这使上传为您发生两次。

    修复是针对您的 maven-assembly-plugin 配置的。

    <attach>false</attach>

    关于Maven maven-deploy-plugin 总是上传两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28407831/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com