我重定向到一个Artifactory的所有Maven仓库的访问具有以下~/.m2/settings.xml
:如何获取Maven项目层次结构的所有远程存储库?
<?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">
<!-- unclear what version changes -> use 1.1.0 because it's higher -->
<servers>
<server>
<id>central</id>
<username>admin</username>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
</server>
</servers>
<mirrors>
<mirror>
<id>artifactory</id>
<name>artifactory</name>
<mirrorOf>*</mirrorOf>
<url>https://[hostname]:[port]/artifactory/remote-repos/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>artifactory</id>
<repositories>
<repository>
<id>central</id>
<name>remote-repos</name>
<url>https://[hostname]:[port]/artifactory/remote-repos</url>
<snapshots>
<enabled>false</enabled>
<updatePolicy>interval:25200</updatePolicy>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<name>remote-repos</name>
<url>https://[hostname]:[port]/artifactory/remote-repos</url>
<snapshots />
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>remote-repos</name>
<url>https://[hostname]:[port]/artifactory/remote-repos</url>
<snapshots>
<enabled>false</enabled>
<updatePolicy>interval:25200</updatePolicy>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>snapshots</id>
<name>remote-repos</name>
<url>https://[hostname]:[port]/artifactory/remote-repos</url>
<snapshots />
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
,因而必须被一个项目(及其子项目)指定的额外远程存储库添加到Artifactory的实例。我目前使用
find . -name pom.xml -exec grep -B 5 -C 5 '<repository>' {} +
如果URL是一个变量并在其他地方声明并且不会跳过重复项,那么它不是非常方便。这不是世界上最糟糕的事情,但也许有一个可以改进的地方。
下不起作用:
mvn versions:display-dependency-updates
不显示远程仓库mvn dependency:list-repositories
只工作到如果启用了该代理第一依赖不能取出,使我有图从哪里得到它,加上研究远程存储库artifactory的或移动~/.m2/settings.xml
一边 - 除上述
该解决方案的SHO find
命令不太方便它包括所有子项目中的所有存储库和儿童子项目等。
它使得很多意义上的解决方案不需要直接从远程存储库直接下载依赖关系,而无需代理服务器如果可能的话,我想立即通过Maven代理转移它们 - 但这不是要求。
运行一些库的依赖可能被宣布。这将使你下载这些依赖关系来找到所需的所有存储库.. –
@StanislavBashkyrtsev我不明白你的意思是“一些存储库可以在依赖项中声明”(POM的“dependencies”部分?) 。 –
你有依赖关系。依赖有它自己的pom。在那个pom中你可能有仓库部分。要知道你首先必须下载该依赖项。 –