[英]Deploying artifacts from a local Gradle artifactory repository to JCenter/MavenCentral
[英]Configure jcenter for only downloading artifacts and Artifactory for deploying artifacts
我们有Artifactory设置,我们使用Maven central repo下载工件,然后自动缓存在Artifactory中。 我们还在Artifactory中上传/部署我们自己的工件。
我现在想用jcenter 替换 Maven central repo,并希望继续使用我们的Artifactory来上传/部署我们自己的工件以及缓存jcenter(以及任何第三方)工件。 我可以要求所有开发人员修改他们的settings.xml文件,因为它将是一次性活动,所以这不是问题。
我在@helmedeiros看到了这个链接,它描述了在settings.xml文件的<repositories>
和<pluginRepositories>
部分进行更改。 但是,这些是我为Artifactory服务器指定URL的部分。 如果我替换我的Artifactory URL,那么这意味着我将能够从jcenter获取和上传工件,这不是我想要的。
我如何确保所有开发人员只能从jcenter拉取(不部署/上传)并仅部署/上传到Artifactory?
以下是我们现在在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">
<servers>
<server>
<username>${security.getCurrentUsername()}</username>
<password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
<id>central</id>
</server>
<server>
<username>${security.getCurrentUsername()}</username>
<password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
<id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>https://inhouse-artifactory/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>https://inhouse-artifactory/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>https://inhouse-artifactory/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>https://inhouse-artifactory/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
我真的很感谢这方面的任何帮助。
我有完全相同的问题:)
我的解决方案是创建一个Artifactory虚拟存储库(forgerock-third-party-virtual)来缓存大多数公共工件。
此虚拟存储库包含基于jcenter的远程存储库:
在虚拟存储库上,没有默认的部署存储库:
因此,使用此设置,我希望开发人员无法推入此虚拟存储库。
根据JFrog文档 ,您在此下拉列表中选择了一个存储库,以便能够进入虚拟存储库。
关于部署设置,我们还有一个父pom,我们在<distributionManagement>
部分中指定了我们自己的存储库。
在我的构建机器上,我添加了这个配置文件(在.m2 / settings.xml中)来缓存工件:
<profile>
<id>force-third-party-repo</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>forgerock-third-party</id>
<name>ForgeRock Third Party Repository</name>
<url>http://maven.forgerock.org/repo/forgerock-third-party-virtual</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>forgerock-third-party</id>
<name>ForgeRock Third Party Repository</name>
<url>http://maven.forgerock.org/repo/forgerock-third-party-virtual</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
我在此文件中有其他设置来声明我们自己的Artifactory存储库(用于推/拉我们自己的工件)+一些Maven凭据。
我用我们的一个Maven项目做了一些测试,它运行正常。
一旦新的.m2 / settings.xml准备就绪,我将在内部Artifactory存储库中推送一个模板,这样开发人员就可以使用curl命令获取此模板。
仅供参考,这是暂时的POC。 我们希望在几天内使用这些设置进行生产。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.