使用Nexus搭建Android私服和应用
2017-04-14 本文已影响0人
Android_小马范儿
场景:若公司Android项目较多,若需要维护公共组件或者lib时,这时候搭建自己的私服或者发布到jcenter上就可以让项目快速搭建和使用最新组件,jcenter的搭建见另外一篇文章,搭建私服的步骤如下:
1、在服务器安装Nexus,拿到账户名和密码
2、新建宿主仓库

3、创建宿主仓库页面

4、宿主仓库建成后,会有一个宿主仓库url

5、在项目build.gradle里增加 mavenLocal()
allprojects {
repositories {
jcenter()
mavenLocal()
}
}
6、在module(要上传的library)项目的build.gradle里增加
apply plugin: 'maven'
uploadArchives{
repositories.mavenDeployer(){
//url地址是宿主仓库地址
repository(url:'http://***********/nexus/content/repositories/sysdk/'){
//用户名和密码是登录私服的用户名和密码
authentication(userName:'*****', password: '********')
}
//compile 'com.******:sysdk:0.0.2' 引用对应下面的名字
pom.version='0.0.2'
pom.artifactId='sysdk'
pom.groupId='com.*****'
}
}
7、module上传到私服,点击红色区域

8、上传成功后就可以引用了
引用的项目需要在build.gradle内增加如下内容:

添加引用
//添加私服引用
compile 'com.******:sysdk:0.0.2'
然后跟引用lib项目一样就可以使用了,感觉就是不一样了。