5

我想向Nexus 中已发布的版本添加两个 zip 。
从本质上讲,它们是应用程序的压缩演示和同一应用程序的扩展版本,也是压缩的。

使用 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 在执行此操作时上传文件并将元数据更新到给定的 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)

这对于 SNAPSHOT 来说不是什么大事,但它完全阻止了发布,因为 Nexus 被配置为拒绝重新部署。

我不认为这种行为是有意的,而且我确信我遗漏了一些东西。我能以某种方式让 Maven 只上传我实际配置的文件吗?

4

3 回答 3

2

因为您没有禁用默认部署机制,所以它仍在执行中。你需要这样的东西:

        <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>
于 2014-02-03T14:24:25.017 回答
2

使用内置部署插件的替代方法(用于部署 Maven 工件):

  • 禁用内置部署机制
  • wagon-maven-plugin为部署阶段启用
  • 将 FTP 凭据添加到HOME/.m2/settings.xml
  • 执行mvn deploy以复制 FTP 文件

<!-- disable standard deploy -->
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-deploy-plugin</artifactId>
  <version>3.0.0-M1</version>
  <executions>
    <execution>
      <id>default-deploy</id>
      <phase>none</phase>
    </execution>
  </executions>
</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>
于 2016-05-31T18:08:58.180 回答
1

为什么不使用可以将工件附加到当前部署的程序集插件,或者使用可以简单地将其他工件附加到您的构建的 build-helper-maven-plugin。在通常的构建过程中使用部署插件是错误的方式。

于 2012-11-30T13:04:48.790 回答