使用gradle在公司的Sonatype Nexus 上搭建项目
参考文章: http://www.open-open.com/lib/view/open1434522817864.html
一、上传library
在已经建好的android library项目的build.gradle文件中,加入以下配置:
apply plugin: 'maven'
buildscript {
repositories {
jcenter()
maven {
url "http://mvnrepo.alibaba-inc.com/mvn/repository"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
uploadArchives {
repositories.mavenDeployer {
pom.project {
pom.groupId = 'com.yunos.tv.androidlib'
pom.artifactId = 'androidlib'
pom.version = '1.0.1-SNAPSHOT'
}
repository(
url: "http://mvnrepo.alibabainc.com/nexus/content/repositories/snapshots") {
authentication(userName: "xxxxxx", password: "xxxxxxx")
}
}
现在在项目根目录执行./gradlew tasks,就可以看到多了一个选项:
Upload tasks
------------
uploadArchives - Uploads all artifacts belonging to configuration ':library:archives'
然后执行
./gradlew uploadArchives
如果没有报错,就成功上传自己的library了。
二. 使用library
repositories {
maven {
url "http://mvnrepo.alibaba-inc.com/nexus/content/repositories/snapshots"
}
}