Question

See photo, I have a jar named "brandstore-repository.jar"

In my localRepository,I delete it.

And artifact:mvn will downloading it in the private server (10.8.12.100)

When i use cmd,use "mvn install" command , downloading it very fast!

But i use "artifact:mvn" in ant building.xml,I feel relatively slow,need to wait for about 10+ seconds/every download!!

enter image description here

My setting.xml which in "${user.home}/.m2", is so easy

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

In my cmd commandline, I use "mvn clean install" instead

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>

very fast

I see, I only use artifact:dependencies ,also can downloading dependency jar,and faster

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

result:

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
Was it helpful?

Solution

Without more details, like your settings.xml and exact commandlines, I can only guess, but one possible reason is that you use different infrastructure in these cases.

That is, for instance:

  • when invoking Maven, your company proxy (nexus or whatever) is used
  • when invoking Ant, some other proxy (or none) is used, resulting in slower transfer

Make sure you always use the same settings.xml plus that you have <mirrors> in it, and that should help you make your transfer paths consistent.

OTHER TIPS

I had the same problem with slow download of artifacts. I was using maven-ant-tasks-2.1.3.jar. I assume your "artifact:mvn" is linked with maven-ant-tasks. Maybe it is not what you're looking for, but I resolved the issue by changing artifact:mvn to exec:

<exec executable="C:/apache-maven-3.0.3/bin/mvn.bat" dir="my-project">
     <arg value="clean" />
     <arg value="install" />
</exec>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top