如何使用Sonatype Nexus和Gradle代理replants? [英] How to use Sonatype Nexus with Gradle to proxy repsitories?

查看:68
本文介绍了如何使用Sonatype Nexus和Gradle代理replants?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在内部服务器上运行了Sonatype Nexus,并且我想用它来代理repo1.maven.org和其他存储库。在Maven中,我只需将< mirror> 配置添加到 settings.xml 。我怎样才能用Gradle做到这一点?



更新:我想这样做,而不必硬编码我的Nexus实例的URL进入我拥有的每一个项目。因此,我正在寻找Maven < mirror> 设置的完全副本。



现在想出的是做这样的事情:

 存储库{
maven {
url $ nexusUrl / content / groups / public

}

然后在每个开发人员的计算机上都有〜/ .gradle / gradle.properties

  nexusUrl = https://nexus.company.com 

然而,这看起来很黑,而且我仍然需要为每个项目添加5行。有没有一种更优雅的方式来做到这一点?

解决方案

初始化脚本可能是最好的方法。请参阅用户指南中的本章。



它们为您提供了一种将逻辑注入所有项目的方法。


Say I have Sonatype Nexus running on an internal server, and I would like to use it to proxy repo1.maven.org and other repositories. In Maven I would simply add a <mirror> configuration to settings.xml. How can I do this with Gradle?

Update: I would like to do this without having to hard-code the URL of my Nexus instance into each and every project I have. So I'm looking for an exact replica of the Maven <mirror> setting.

The best I could come up with for now is to do something like this:

repositories {
    maven {
        url "$nexusUrl/content/groups/public"
    }
}

And then have this in ~/.gradle/gradle.properties on each developer's computer:

nexusUrl = https://nexus.company.com

However, this looks hacked, and I still have to add the 5 lines to each project. Is there a more elegant way to do this?

解决方案

Init scripts might be the best way to go. Take a look at this chapter in the User Guide.

They provide a way for you to inject logic into all of your projects.

这篇关于如何使用Sonatype Nexus和Gradle代理replants?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆