How do I download a Maven artifact at the command line without using dependency:get or maven-download-plugin?

前端 未结 5 1577
温柔的废话
温柔的废话 2020-12-24 06:18

I\'d like to download an artifact and its dependencies at the command line. I.e.

mvn [some plugin]:[goal] -DartifactId=[artifactId] -DgroupId=[groupId] -Dver         


        
相关标签:
5条回答
  • 2020-12-24 06:42

    The simplest solution would be to create a simple pom with the appropriate dependencies and do mvn clean package on that mini project...

    0 讨论(0)
  • 2020-12-24 06:45

    Try using the latest version of dependency:get, it works for me

    mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DartifactId=[artifactId] -DgroupId=[groupId] -Dversion=[version]
    

    works for me

    0 讨论(0)
  • 2020-12-24 06:52

    Example to download version 6.9.4 of TestNG to your local ~/.m2/repository (uses maven-dependency-plugin:get):

    mvn org.apache.maven.plugins:maven-dependency-plugin:RELEASE:get \
    -Dartifact=org.testng:testng:6.9.4:jar
    

    Example to download version 4.11 of JUnit to your current working directory (uses maven-dependency-plugin:copy):

    mvn org.apache.maven.plugins:maven-dependency-plugin:RELEASE:copy \
    -Dartifact=junit:junit:4.11:jar
    
    0 讨论(0)
  • 2020-12-24 06:58

    The copy goal is more appropriate here and it lets you specify an output directory as well (which is deprecated in the get goal):

    mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:copy -Dartifact=groupId:artifactId:version[:packaging][:classifier] -DoutputDirectory=[target] -Dmdep.useBaseVersion=true

    mdep.useBaseVersion=true will remove timestamps from snapshot builds.

    0 讨论(0)
  • 2020-12-24 07:00

    this is the method that I use, matches your need but less typing and brain cell consumption:

    curl https://start.spring.io/starter.tgz | tar -xzvf -

    (btw, you can add -d dependencies=lombok when the dependency you want is listed on starter like lombok.)

    And then, in vim pom.xml, delete whatever parent and modify everything between dependencies. you just need to fill in group, artifact and version.

    Finally, mvn package. It starts to download...

    0 讨论(0)
提交回复
热议问题