每当我执行以下命令时,我都会观察:-
mvn -f pom.xml -Dmaven.repo.local=$MAVEN_REPO -Drat.skip=true -DnoTest=true surefire-report:report
maven 每次都会下载 maven-metadata
和插件 Artifact 。
Downloading: http://maven.twttr.com/com/neveda/kekin-storage-metrics/0.001-SNAPSHOT/maven-metadata.xml
...
Downloading: http://artifactory.kekin.local:XXXX/libs-release/org/
我已经浏览过this答案和我的 settings.xml
如下所示:-
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://artifactory.kekin.local:XXXX/libs-release</url>
</repository>
<repository>
<snapshots>
<updatePolicy>never</updatePolicy>
</snapshots>
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://artifactory.kekin.local:XXXX/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://artifactory.kekin.local:XXXX/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots>
<updatePolicy>never</updatePolicy>
</snapshots>
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://artifactory.kekin.local:XXXX/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
环境:-
- Maven - 3.5
- 操作系统 - 10.12.6
最佳答案
我不确定这是否适合您,但您可以使用 --offline
开关调用 maven 以阻止它进行任何下载:
mvn --offline -f pom.xml -Dmaven.repo.local=$MAVEN_REPO -Drat.skip=true -DnoTest=true surefire-report:report
但这有一个副作用,如果缺少任何 Artifact ,您的构建将会失败。
关于java - 防止 maven 每次下载 maven-metadata 和插件 Artifact ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45733701/