防止 maven 每次下载 maven-metadata 和插件工件



每当我执行以下命令时,我都会观察:-

mvn -f pom.xml -Dmaven.repo.local=$MAVEN_REPO -Drat.skip=true -DnoTest=true surefire-report:report

Maven每次都会下载maven-metadata和插件工件。

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/

我已经完成了这个答案,我的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>

环境:-

  • 梅文 - 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

但是,这有一个副作用,即如果缺少任何工件,您的构建将失败。

最新更新