【问题标题】:Maven download source codes command line using POM.xmlMaven下载源码命令行使用POM.xml
【发布时间】:2013-07-21 21:42:24
【问题描述】:

我想使用maven2命令行界面下载json-simple库的源代码。所以,我把这个 .pom 文件下载到 ~/project/pom.xml

http://json-simple.googlecode.com/svn/trunk/pom.xml

然后,使用相关 SO 问题的答案:How to install Maven artifact with sources from command line?,我尝试使用以下命令下载源代码,

$ cd ~/project
$ mvn eclipse:eclipse -DdownloadSources=true
$ ls

输出只是pom.xml。怎么了?

$ mvn --version

Apache Maven 2.2.1 (rdebian-8)

【问题讨论】:

    标签: maven-2


    【解决方案1】:

    使用dependency 插件的get 目标

    完整的命令行(在某处执行 - 你不需要 pom)

    mvn -DgroupId=com.googlecode.json-simple 
      -DartifactId=json-simple 
      -Dversion=1.1.1 
      -Dclassifier=sources 
      -DremoteRepositories=http://nexus.dmz1.heuboe.hbintern:8080/nexus/content/repositories/central/ 
      org.apache.maven.plugins:maven-dependency-plugin:2.8:get
    

    或作为单行者

    mvn -DgroupId=com.googlecode.json-simple -DartifactId=json-simple -Dversion=1.1.1 -Dclassifier=sources -DremoteRepositories=http://nexus.dmz1.heuboe.hbintern:8080/nexus/content/repositories/central/ org.apache.maven.plugins:maven-dependency-plugin:2.8:get
    

    通常我使用的是 Maven 3,但我也在 Windows 上使用 Maven 2.2.1 进行了测试,它可以工作。

    您也可以考虑在 eclipse 中使用 m2e Maven Integration(如果尚未安装,请查看 eclipse Marketplace 以安装它)而不是 maven-eclipse-plugin (eclipse:eclipse)。你比有一个 Eclipse 偏好选项来下载源代码。

    【讨论】:

    • 构建失败。您必须至少指定一个目标或生命周期阶段才能执行构建步骤。
    • @celebisait 可能没有正确复制到一行。拿我添加的oneliner。
    • 我还是有问题。当我使用您的单行命令时,我得到以下输出:Scanning for projects... Building Maven Default Project task-segment: [org.apache.maven.plugins:maven-dependency-plugin:2.8:get] (aggregator-style) [dependency:get {execution: default-cli}] Resolving com.googlecode.json-simple:json-simple:jar:sources:1.1.1 with transitive dependencies BUILD SUCCESSFUL。但是,我找不到源代码。什么都没有下载。
    • @celebisait 您将在.../.m2/repository/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1-sources.jar找到下载的 jar 工件内的源代码
    • 为什么它不能使用-Dartifact 参数而不是那三个? 编辑: 我的错误,我没有阅读@ 987654324@ 很好,并从artifact 参数字符串中省略了classifier
    猜你喜欢
    • 2014-09-24
    • 1970-01-01
    • 2013-10-09
    • 2011-03-30
    • 1970-01-01
    • 2013-07-09
    • 1970-01-01
    • 1970-01-01
    • 2016-01-12
    相关资源
    最近更新 更多