whirly
V2EX  ›  问与答

v2exer 问下 gradle 私服问题

  •  
  •   whirly · Jul 30, 2019 · 1780 views
    This topic created in 2500 days ago, the information mentioned may be changed or developed.

    据我上网了解貌似 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 replies    2019-07-30 19:45:22 +08:00
    imzcg
        1
    imzcg  
       Jul 30, 2019 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  
       Jul 30, 2019 via Android
    像这样<url>http://xxx.xx.xx.xx:8081/nexus/content/groups/public/</url>,没有 mirrors
    imzcg
        3
    imzcg  
       Jul 30, 2019 via Android
    而且私服地址可以在浏览器进行访问。你试试,不行就不对
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1607 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 16:33 · PVG 00:33 · LAX 09:33 · JFK 12:33
    ♥ Do have faith in what you're doing.