How can I download a specific Maven artifact in one command line?

前端 未结 11 962
太阳男子
太阳男子 2020-11-28 01:05

I can install an artifact by install:install-file, but how can I download an artifact?

For example:

mvn download:download-file -Dgroup         


        
11条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 01:24

    With the latest version (2.8) of the Maven Dependency Plugin, downloading an artifact from the Maven Central Repository is as simple as:

    mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -Dartifact=groupId:artifactId:version[:packaging[:classifier]]
    

    where groupId:artifactId:version, etc. are the Maven coordinates

    An example, tested with Maven 2.0.9, Maven 2.2.1, and Maven 3.0.4:

    mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -Dartifact=org.hibernate:hibernate-entitymanager:3.4.0.GA:jar:sources
    

    (Thanks to Pascal Thivent for providing his wonderful answer in the first place. I am adding another answer, because it wouldn't fit in a comment and it would be too extensive for an edit.)

提交回复
热议问题