1

看照片,我有一个名为“brandstore-repository.jar”的罐子

在我的 localRepository 中,我将其删除。

并且 artifact:mvn 会下载到私有服务器(10.8.12.100)

当我使用cmd时,使用“mvn install”命令,下载速度非常快!

但是我在ant building.xml中使用了“artifact:mvn”,感觉比较慢,需要等待大约10+秒/每次下载!!

在此处输入图像描述

我在“${user.home}/.m2”中的setting.xml,非常简单

<settings 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/settings-1.0.0.xsd">

    <localRepository>D:\FeiLong Soft\Essential\Development\repository</localRepository>

    <profiles>
        <profile>
            <id>profile-baozun</id>
            <repositories>
                <repository>
                    <id>public</id>
                    <url>http://10.8.12.100/nexus/content/groups/public</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>profile-baozun</activeProfile>
    </activeProfiles>
</settings>

在我的 cmd 命令行中,我改用“mvn clean install”

E:\Workspaces\baozun\converseplatform\converse-repo>mvn clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building converse-repo
[INFO]    task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory E:\Workspaces\baozun\converseplatform\converse-repo\target
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 7 resources
Downloading: http://10.8.12.100/nexus/content/groups/public/com/jumbo/brandstore/brandstore-repository/4.0.0/brandstore-repository-4.0.0.pom
1K downloaded  (brandstore-repository-4.0.0.pom)
Downloading: http://10.8.12.100/nexus/content/groups/public/com/jumbo/brandstore/brandstore/4.0.0/brandstore-4.0.0.pom
17K downloaded  (brandstore-4.0.0.pom)
Downloading: http://10.8.12.100/nexus/content/groups/public/com/jumbo/brandstore/brandstore-repository/4.0.0/brandstore-repository-4.0.0.jar
913K downloaded  (brandstore-repository-4.0.0.jar)
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 87 source files to E:\Workspaces\baozun\converseplatform\converse-repo\target\classes
[INFO] [native2ascii:native2ascii {execution: native2ascii}]
[INFO] Includes: [**/*.properties]
[INFO] Excludes: []
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 20 resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Compiling 12 source files to E:\Workspaces\baozun\converseplatform\converse-repo\target\test-classes
[INFO] [surefire:test {execution: default-test}]
[INFO] Tests are skipped.
[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: E:\Workspaces\baozun\converseplatform\converse-repo\target\converse-repo-4.0.0.jar
[INFO] [install:install {execution: default-install}]
[INFO] Installing E:\Workspaces\baozun\converseplatform\converse-repo\target\converse-repo-4.0.0.jar to D:\FeiLong Soft\Essential\Development\repository\com\jum
bo\converse\converse-repo\4.0.0\converse-repo-4.0.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Wed Nov 28 11:03:17 CST 2012
[INFO] Final Memory: 39M/94M
[INFO] ------------------------------------------------------------------------
E:\Workspaces\baozun\converseplatform\converse-repo>

非常快

我明白了,我只使用 artifact:dependencies ,也可以下载依赖jar,而且速度更快

<target name="maven-test">
    <artifact:pom id="feilongMaven" file="pom.xml" />

    <artifact:dependencies filesetId="feilong.maven.dependencies.fileset" pathid="feilong.maven.dependencies.runtime" useScope="runtime">
        <pom refid="feilongMaven" />
    </artifact:dependencies>
</target>

结果:

maven-test:
[artifact:dependencies] Downloading: com/jumbo/brandstore/brandstore-repository/4.0.0/brandstore-repository-4.0.0.pom from repository public at http://10.8.12.100/nexus/content/groups/public
[artifact:dependencies] Transferring 2K from public
[artifact:dependencies] Downloading: com/jumbo/brandstore/brandstore/4.0.0/brandstore-4.0.0.pom from repository public at http://10.8.12.100/nexus/content/groups/public
[artifact:dependencies] Transferring 18K from public
[artifact:dependencies] Downloading: com/jumbo/brandstore/brandstore-repository/4.0.0/brandstore-repository-4.0.0.jar from repository public at http://10.8.12.100/nexus/content/groups/public
[artifact:dependencies] Transferring 914K from public
BUILD SUCCESSFUL
Total time: 1 second
4

2 回答 2

1

如果没有更多详细信息,例如您的 settings.xml 和确切的命令行,我只能猜测,但一个可能的原因是您在这些情况下使用了不同的基础架构。

也就是说,例如:

  • 调用 Maven 时,使用您的公司代理(nexus 或其他)
  • 调用 Ant 时,使用了其他代理(或不使用),导致传输速度变慢

确保您始终使用与其中相同的settings.xml加号,<mirrors>这应该有助于您使传输路径保持一致。

于 2012-11-27T16:16:56.510 回答
0

我在工件下载缓慢时遇到了同样的问题。我正在使用 maven-ant-tasks-2.1.3.jar。我假设您的“工件:mvn”与 maven-ant-tasks 相关联。也许这不是您想要的,但我通过将 artifact:mvn 更改为 exec 解决了这个问题:

<exec executable="C:/apache-maven-3.0.3/bin/mvn.bat" dir="my-project">
     <arg value="clean" />
     <arg value="install" />
</exec>
于 2012-12-13T14:12:31.283 回答