【问题标题】:How to speed up maven-deploy-plugin to deploy artifacts to the Artifactroy?如何加快 maven-deploy-plugin 将工件部署到 Artifactroy?
【发布时间】:2018-08-30 08:51:56
【问题描述】:

我正在使用 Maven 版本 3.5.4 和 maven-deploy-plugin 版本 2.8.2 将我的工件部署到 Artifactory 版本 6.3.2

当我执行mvn deploy -DdeployAtEnd=true 时,每个模块需要大约 2 分钟以上的时间。我有 15 个模块,总时间大约需要 30 多分钟。

我们有什么方法可以加快这个过程吗?

这是我的 Maven 信息

Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 
    2018-06-18T01:33:14+07:00)
Maven home: C:\Java.Application\Apache\apache-maven-3.5.4\bin\..
Java version: 1.8.0_181, vendor: Oracle Corporation, 
    runtime: C:\Java.Application\Sun\Java\jdk1.8.0_181\jre
Default locale: en_US, platform encoding: UTF-8
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

神器artifactroy.log

2018-08-30 15:08:16,496 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml.md5' Content-Length: 32
2018-08-30 15:08:19,550 - Deploy to 'core-snapshot-local:/some/artifact/maven-metadata.xml' Content-Length: 416
2018-08-30 15:08:22,677 - Deploy to 'core-snapshot-local:/some/artifact/maven-metadata.xml.sha1' Content-Length: 40
2018-08-30 15:08:25,731 - Deploy to 'core-snapshot-local:/some/artifact/maven-metadata.xml.md5' Content-Length: 32
2018-08-30 15:08:28,800 - Deploy to 'core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-javadoc.jar' Content-Length: 110853
2018-08-30 15:08:32,016 - Deploy to 'core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-javadoc.jar.sha1' Content-Length: 40
2018-08-30 15:08:35,100 - Deploy to 'core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-javadoc.jar.md5' Content-Length: 32
2018-08-30 15:08:38,182 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml' Content-Length: 1868
2018-08-30 15:08:41,413 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml.sha1' Content-Length: 40
2018-08-30 15:08:42,249 - Indexing archive: core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7.jar
2018-08-30 15:08:42,336 - Indexing archive: core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-javadoc.jar
2018-08-30 15:08:44,462 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml.md5' Content-Length: 32
2018-08-30 15:08:47,520 - Deploy to 'core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-test-javadoc.jar' Content-Length: 221096
2018-08-30 15:08:50,731 - Deploy to 'core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-test-javadoc.jar.sha1' Content-Length: 40
2018-08-30 15:08:53,816 - Deploy to 'core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-test-javadoc.jar.md5' Content-Length: 32
2018-08-30 15:08:56,912 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml' Content-Length: 1868
2018-08-30 15:08:59,973 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml.sha1' Content-Length: 40
2018-08-30 15:09:03,027 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml.md5' Content-Length: 32
2018-08-30 15:09:06,084 - Deploy to 'core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-sources.jar' Content-Length: 19103
2018-08-30 15:09:09,293 - Deploy to 'core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-sources.jar.sha1' Content-Length: 40
2018-08-30 15:09:12,886 - Deploy to 'core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-sources.jar.md5' Content-Length: 32
2018-08-30 15:09:16,032 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml' Content-Length: 1868
2018-08-30 15:09:19,086 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml.sha1' Content-Length: 40
2018-08-30 15:09:22,136 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml.md5' Content-Length: 32
2018-08-30 15:09:25,196 - Deploy to 'core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-test-sources.jar' Content-Length: 66693
2018-08-30 15:09:28,455 - Deploy to 'core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-test-sources.jar.sha1' Content-Length: 40
2018-08-30 15:09:31,573 - Deploy to 'core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-test-sources.jar.md5' Content-Length: 32
2018-08-30 15:09:34,665 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml' Content-Length: 1868
2018-08-30 15:09:37,717 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml.sha1' Content-Length: 40
2018-08-30 15:09:40,771 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml.md5' Content-Length: 32
2018-08-30 15:09:42,250 - Indexing archive: core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-test-javadoc.jar
2018-08-30 15:09:42,499 - Indexing archive: core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-sources.jar
2018-08-30 15:09:42,565 - Indexing archive: core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-test-sources.jar
2018-08-30 15:09:43,832 - Deploy to 'core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-tests.jar' Content-Length: 60117
2018-08-30 15:09:47,060 - Deploy to 'core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-tests.jar.sha1' Content-Length: 40
2018-08-30 15:09:50,309 - Deploy to 'core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-tests.jar.md5' Content-Length: 32
2018-08-30 15:09:53,402 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml' Content-Length: 1868
2018-08-30 15:09:56,458 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml.sha1' Content-Length: 40
2018-08-30 15:09:59,509 - Deploy to 'core-snapshot-local:/some/artifact/some/version/maven-metadata.xml.md5' Content-Length: 32

神器access.log

2018-08-30 15:07:48,401 [ACCEPTED DOWNLOAD] core-snapshot-local:/some/artifact/some/version/maven-metadata.xml for some-user/some-ip.
2018-08-30 15:07:48,456 [ACCEPTED DOWNLOAD] core-snapshot-local:/some/artifact/some/version/maven-metadata.xml.sha1 for some-user/some-ip.
2018-08-30 15:07:51,641 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/some/version/maven-metadata.xml for some-user/some-ip.
2018-08-30 15:07:51,642 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7.jar for some-user/some-ip.
2018-08-30 15:08:00,997 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/some/version/maven-metadata.xml for some-user/some-ip.
2018-08-30 15:08:00,997 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7.pom for some-user/some-ip.
2018-08-30 15:08:01,079 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/maven-metadata.xml for some-user/some-ip.
2018-08-30 15:08:07,271 [ACCEPTED DOWNLOAD] core-snapshot-local:/some/artifact/maven-metadata.xml for some-user/some-ip.
2018-08-30 15:08:07,328 [ACCEPTED DOWNLOAD] core-snapshot-local:/some/artifact/maven-metadata.xml.sha1 for some-user/some-ip.
2018-08-30 15:08:19,594 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/maven-metadata.xml for some-user/some-ip.
2018-08-30 15:08:28,919 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/some/version/maven-metadata.xml for some-user/some-ip.
2018-08-30 15:08:28,920 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-javadoc.jar for some-user/some-ip.
2018-08-30 15:08:47,637 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/some/version/maven-metadata.xml for some-user/some-ip.
2018-08-30 15:08:47,639 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-test-javadoc.jar for some-user/some-ip.
2018-08-30 15:09:06,192 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/some/version/maven-metadata.xml for some-user/some-ip.
2018-08-30 15:09:06,193 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-sources.jar for some-user/some-ip.
2018-08-30 15:09:25,295 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/some/version/maven-metadata.xml for some-user/some-ip.
2018-08-30 15:09:25,297 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-test-sources.jar for some-user/some-ip.
2018-08-30 15:09:43,950 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/some/version/maven-metadata.xml for some-user/some-ip.
2018-08-30 15:09:43,951 [ACCEPTED DEPLOY] core-snapshot-local:/some/artifact/some/version/my-artifact-1.0.2-20180830.080748-7-tests.jar for some-user/some-ip.

编辑 1

之前我发现了一些关于 Maven 3.5.2 here 的问题,这让我了解了 Maven 3.3.93.5.xwagon 版本)之间的区别。

  • Maven 3.3.9 使用旅行车版本2.10
  • Maven 3.5.4 使用旅行车版本3.1.0

再次,我将 maven_home/lib 从 Maven 3.3.9 复制到 Maven 3.5.4。一切都恢复得很快,一共 2-3 分钟。

我还有机会将 maven_home/lib 从 Maven 3.5.4 复制到 Maven 3.3.9。进程又慢了。

编辑 2

即使使用wagon 版本2.10 作为临时解决方案似乎可行,我也开放使用Maven 3.5.4 的正确方法,并希望您能有所启发。

【问题讨论】:

  • maven-deploy-plugin 太慢了!!!

标签: maven artifactory maven-deploy-plugin


【解决方案1】:

由于wagon 版本2.10 似乎更好,所以临时解决方案是在我的pom.xml 中添加这些旅行车作为扩展,如下所示:-

<properties>
    <my.wagon.vesion>2.10</my.wagon.vesion>
</properties>

<build>
    <extensions>
        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-file</artifactId>
            <version>${my.wagon.vesion}</version>
        </extension>
        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-http-shared</artifactId>
            <version>${my.wagon.vesion}</version>
        </extension>
        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-http</artifactId>
            <version>${my.wagon.vesion}</version>
        </extension>
        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-provider-api</artifactId>
            <version>${my.wagon.vesion}</version>
        </extension>
    </extensions>
</build>

【讨论】:

    【解决方案2】:

    不要将-DdeployAtEnd 与常规 maven 部署插件一起使用。

    它很慢,因为它只会串联而不是并行上传模块。

    相反,我建议您使用两步 CI 来模拟 -DdeployAtEnd

    mvn install
    mvn -T 4C deploy -Dmaven.install.skip=true -DskipTests=true #basically skip everything but jar.
    

    你可以把 -T 放在你认为允许尽可能多的上传发生的任何地方。

    它仍然不理想,因为 maven 部署插件只会并行化上述大部分内容。

    另一种解决方案是尝试使用nexus deploy 插件,它基本上“分阶段”部署,并有更快的方式一次上传整个东西,但这通常需要一个nexus repo IIRC。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-26
      • 2018-08-09
      • 2016-10-19
      • 2021-10-28
      • 2014-01-27
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      相关资源
      最近更新 更多