v2exer 问下 gradle 私服问题

2019-07-30 19:15:21 +08:00
 whirly

据我上网了解貌似 gradle 可以用 maven 私服的源,但是我对 gradle 不熟,不知道怎么配置,v 友来帮帮忙

首先公司的电脑不能连外网,已有 nexus3 maven2 私服,现在有个 Java 项目需要 gradle,怎么配置仓库呢?

因为 Java 不是公司的主要开发语言,gradle 也没什么人用过

我修改 init.gradle 全局配置

    allprojects {
        repositories {
			maven {
				url "http://mirrors.myhost.org/maven2/"
			}
        }
     }

http://mirrors.myhost.org/maven2/ 是 maven 私服地址,但是好像无用

网上有阿里的镜像源是这样的

allprojects {
    repositories {
        maven {
            url "http://maven.aliyun.com/nexus/content/groups/public"
        }
    }
}

现在我想加一个 gradle 镜像该怎么做呢? :disappointed_relieved:

1176 次点击
所在节点    问与答
3 条回复
imzcg
2019-07-30 19:42:49 +08:00
<localRepository>E:\***\repository</localRepository> //本地仓库地址,先行创建好文件夹


//nexus 服务
<server>
<id>my-nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>my-nexus-snapshot</id>
<username>admin</username>
<password>admin123</password>
</server>

//镜像

<mirror>
<id>nexus</id>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<mirrorOf>*</mirrorOf>
</mirror>

//nexus 仓库配置

<profile>
<id>nexusProfile</id>
<repositories>
<repository>
<id>nexus</id>
<name>Nexus Repository</name>
<url>http://xxx.xx.xx.xx:8081/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>

//激活
<activeProfiles>
<activeProfile>nexusProfile</activeProfile>
</activeProfiles>
imzcg
2019-07-30 19:44:08 +08:00
像这样<url>http://xxx.xx.xx.xx:8081/nexus/content/groups/public/</url>,没有 mirrors
imzcg
2019-07-30 19:45:22 +08:00
而且私服地址可以在浏览器进行访问。你试试,不行就不对

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/587627

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX