【发布时间】:2016-06-05 12:08:02
【问题描述】:
我正在尝试从我的远程存储库(Artifactory)下载最后一个快照版本。为此,我正在使用以下命令:
mvn dependency:get \
-Dartifact=com.acme:my-application:LATEST:war \
-DremoteRepositories=http://localhost:8085/artifactory/libs-snapshots-local/
libs-snapshot-local 存储库是 Artifactory 的一部分,所有快照都存储在其中。如果我在以下路径打开 maven-metadata.xml 文件:
http://localhost:8085/artifactory/libs-snapshots-local/com/acme/my-application/maven-metadata.xml
然后我得到以下 XML 响应:
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.acme</groupId>
<artifactId>my-application</artifactId>
<version>2.0.0-20160222.105839-1</version>
<versioning>
<latest>2.0.0-SNAPSHOT</latest>
<versions>
<version>2.0.0-SNAPSHOT</version>
</versions>
<lastUpdated>20160223132257</lastUpdated>
</versioning>
</metadata>
所以,根据这个文件,版本2.0.0-SNAPSHOT的WAR应该是检索到的那个。
但是,当我执行命令时,我得到以下响应:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:get (default-cli) @ standalone-pom ---
[INFO] Resolving com.acme:my-application:war:LATEST with transitive dependencies
Downloading: http://download.java.net/maven/2/com/acme/my-application/maven-metadata.xml
Downloading: http://localhost:8085/artifactory/libs-releases/com/acme/my-application/maven-metadata.xml
Downloading: http://repo1.maven.org/maven2/com/acme/my-application/maven-metadata.xml
Downloading: http://localhost:8085/artifactory/libs-snapshots/com/acme/my-application/maven-metadata.xml
Downloading: http://localhost:8085/artifactory/libs-snapshots-local/com/acme/my-application/maven-metadata.xml
Downloaded: http://localhost:8085/artifactory/libs-snapshots-local/com/acme/my-application/maven-metadata.xml (378 B at 23.1 KB/sec)
Downloaded: http://localhost:8085/artifactory/libs-snapshots/com/acme/my-application/maven-metadata.xml (378 B at 0.5 KB/sec)
Downloaded: http://localhost:8085/artifactory/libs-releases/com/acme/my-application/maven-metadata.xml (898 B at 0.6 KB/sec)
Downloading: http://localhost:8085/artifactory/libs-releases/com/acme/my-application/1.0.0/my-application-1.0.0.pom
Downloaded: http://localhost:8085/artifactory/libs-releases/com/acme/my-application/1.0.0/my-application-1.0.0.pom (26 KB at 1475.0 KB/sec)
Downloading: http://localhost:8085/artifactory/libs-releases/com/acme/my-application/1.0.0/my-application-1.0.0.war
Downloaded: http://localhost:8085/artifactory/libs-releases/com/acme/my-application/1.0.0/my-application-1.0.0.war (77415 KB at 9657.4 KB/sec)
看起来dependency:get 目标正在尝试通过查看我的 settings.xml 文件中的所有存储库和 -DremoteRepositories 参数来下载工件。
因此,它也在查看我的发布存储库,其中包含一个发布 1.0.0,该发布晚于 2.2.0-SNAPSHOT 上传。
我的 settings.xml 文件如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
<pluginGroup>org.mortbay.jetty</pluginGroup>
</pluginGroups>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-releases</name>
<url>http://localhost:8085/artifactory/libs-releases</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshots</name>
<url>http://localhost:8085/artifactory/libs-snapshots</url>
</repository>
<repository>
<id>Maven</id>
<name>Maven Repository</name>
<url>http://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>Java</id>
<name>Java Repository</name>
<url>http://download.java.net/maven/2/</url>
</repository>
</repositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
有没有办法告诉maven-dependency-plugin 不要使用settings.xml 中定义的存储库,而只使用命令中给出的依赖项?
【问题讨论】:
-
为什么不通过
mvn -U ...简单地使用maven本身呢?
标签: java maven artifactory maven-dependency-plugin