安卓学习

Nexus搭建maven私服-Android上传aar和依赖(3

2018-09-19  本文已影响204人  CokeNello

前言:公司有几个项目都要依赖同一个底层模块X,而这些项目都在不同大牛手上维护着,而又不可能直接上传到公共的仓库,于是就在自己的服务器上弄一个仓库。
PS,基于VMWare上的CenterOS6,搭建的Nexus私服。

0. Thanks

AndroidStudio 使用gradle 脚本上传aar文件到Nexus Maven 私有服务器

1. Nexus创建自己的仓库

访问:http://192.168.239.10:8081/nexus,当然你的IP不一定是这个。

先创建一个你要上传的仓库信息:

1.png

2. Android Studio 配置

...
apply plugin: 'maven'
...
uploadArchives {
    repositories.mavenDeployer {
        // 修改为自己刚才创建的仓库地址
        repository(url: "http://192.168.239.10:8081/nexus/content/repositories/com.tibby.hello/") {
            authentication(userName: "admin", password: "1421")
        }
        pom.version = "1.0.2"
        pom.artifactId = "helloworld"
        pom.groupId = "com.tibby.hello"
        pom.name = "hello"
        pom.packaging = 'aar'
    }
}

groupId,version要注意填好。

3.png

点击后即可编译上传,success后就可以了。

2.png

3. Android Studio 中引用

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    //添加仓库
    repositories {
        maven {
            url "http://192.168.239.10:8081/nexus/content/repositories/com.tibby.hello/"
        }
    }
    compile 'com.tibby.hello:helloworld:1.0.1@aar'
}
上一篇下一篇

猜你喜欢

热点阅读