Maven 无法在远程文件存储库中找到工件
Maven can't find artifacts in remote file repository
背景:我正在封闭网络中处理一个maven项目,这意味着我无法连接到Maven Central。我有一个存储库文件夹,其中包含我需要的所有工件,包括插件和 Maven 工件。另外,我无法使用或安装 Nexus。
问题:我想 运行 使用 maven 3.6.0 / jdk 1.8.0_162 的 Jenkins 作业。我的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">
<localRepository>D:\Maven\repository</localRepository>
<interactiveMode>false</interactiveMode>
<offline>false</offline>
<pluginGroups />
<proxies />
<servers />
<mirrors>
<mirror>
<id>ExternalRespositoryMirror</id>
<name>Maven External Repository Mirror</name>
<url>file://myserver/repository/maven/repository</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>jenkins</id>
<repositories>
<repository>
<id>central</id>
<name>Maven External Dependencies Repository</name>
<url>file://myserver/repository/maven/repository</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven External Plugins Repository</name>
<url>file://myserver/repository/maven/repository</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>jenkins</activeProfile>
</activeProfiles>
</settings>
我的 POM 没有存储库部分,因为 jenkins slave 应该决定从哪里获取这些。
构建时,出现以下错误:
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-clean-plugin:jar:2.5 in ExternalRespositoryMirror (file://myserver/repository/maven/repository) -> [Help 1]
我可以打开文件:// url 并且工件 "maven-clean-plugin-2.5.jar" 在文件夹 \maven\repository\org\apache\maven\plugins\maven-clean-plugin.5
中
maven 找不到工件的原因可能是什么?它存在于本地存储库 (D:\Maven\repository) 中,因此它实际上不应该查询网络存储库。
您可能只想尝试将 jars 安装到本地存储库中,而只是跳过远程方面。 Maven 会在远程访问之前查看本地存储库。
Guide to installing 3rd party JARs
创建一个 pom 来进行复制,将其绑定到 process-resources 阶段。您可以从已知位置拉取它们(例如:scp/robocopy/unzip)(不要检查 VCS;不好的做法,浪费 space)并安装它们。
fyi,这与 aether-ant Tasks 的作用相反,后者是从 amaven 存储库中拉取并复制到目标目录,这对于 ant 构建以使用来自 (nexus) 存储库的 jar 很有用,请参阅:
背景:我正在封闭网络中处理一个maven项目,这意味着我无法连接到Maven Central。我有一个存储库文件夹,其中包含我需要的所有工件,包括插件和 Maven 工件。另外,我无法使用或安装 Nexus。
问题:我想 运行 使用 maven 3.6.0 / jdk 1.8.0_162 的 Jenkins 作业。我的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">
<localRepository>D:\Maven\repository</localRepository>
<interactiveMode>false</interactiveMode>
<offline>false</offline>
<pluginGroups />
<proxies />
<servers />
<mirrors>
<mirror>
<id>ExternalRespositoryMirror</id>
<name>Maven External Repository Mirror</name>
<url>file://myserver/repository/maven/repository</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>jenkins</id>
<repositories>
<repository>
<id>central</id>
<name>Maven External Dependencies Repository</name>
<url>file://myserver/repository/maven/repository</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven External Plugins Repository</name>
<url>file://myserver/repository/maven/repository</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>jenkins</activeProfile>
</activeProfiles>
</settings>
我的 POM 没有存储库部分,因为 jenkins slave 应该决定从哪里获取这些。
构建时,出现以下错误:
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-clean-plugin:jar:2.5 in ExternalRespositoryMirror (file://myserver/repository/maven/repository) -> [Help 1]
我可以打开文件:// url 并且工件 "maven-clean-plugin-2.5.jar" 在文件夹 \maven\repository\org\apache\maven\plugins\maven-clean-plugin.5
中maven 找不到工件的原因可能是什么?它存在于本地存储库 (D:\Maven\repository) 中,因此它实际上不应该查询网络存储库。
您可能只想尝试将 jars 安装到本地存储库中,而只是跳过远程方面。 Maven 会在远程访问之前查看本地存储库。
Guide to installing 3rd party JARs
创建一个 pom 来进行复制,将其绑定到 process-resources 阶段。您可以从已知位置拉取它们(例如:scp/robocopy/unzip)(不要检查 VCS;不好的做法,浪费 space)并安装它们。
fyi,这与 aether-ant Tasks 的作用相反,后者是从 amaven 存储库中拉取并复制到目标目录,这对于 ant 构建以使用来自 (nexus) 存储库的 jar 很有用,请参阅: