V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
whirly
V2EX  ›  问与答

v2exer 问下 gradle 私服问题

  •  
  •   whirly · 2019-07-30 19:15:21 +08:00 · 1162 次点击
    这是一个创建于 1703 天前的主题,其中的信息可能已经有所发展或是发生改变。

    据我上网了解貌似 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:

    3 条回复    2019-07-30 19:45:22 +08:00
    imzcg
        1
    imzcg  
       2019-07-30 19:42:49 +08:00 via Android   ❤️ 1
    <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
        2
    imzcg  
       2019-07-30 19:44:08 +08:00 via Android
    像这样<url>http://xxx.xx.xx.xx:8081/nexus/content/groups/public/</url>,没有 mirrors
    imzcg
        3
    imzcg  
       2019-07-30 19:45:22 +08:00 via Android
    而且私服地址可以在浏览器进行访问。你试试,不行就不对
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1713 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 16:42 · PVG 00:42 · LAX 09:42 · JFK 12:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.