月度归档:2016年01月

gradle发布Android library到私有mvn仓库

前置条件:

  1. 有私有maven仓库,一般都是:nexus-oss
  2. 发布到公共maven仓库:gradle-mvn-push

配置步骤:

一、配置私有仓库的地址和用户名/密码
VERSION_NAME=1.0.1-SNAPSHOT
#VERSION_NAME=1.0.1
VERSION_CODE=101

POM_GROUP=com.github.captain-miao
POM_ARTIFACT_ID=common
POM_PACKAGING=aar


POM_NAME=Android Common library
POM_DESCRIPTION=Android Common library


POM_URL=http://127.0.0.1/android/android-common
POM_SCM_URL=http://127.0.0.1/android/android-common
POM_SCM_CONNECTION=scm:http://127.0.0.1/android/android-common.git
POM_SCM_DEV_CONNECTION=scm:http://127.0.0.1/android/android-common.git


POM_LICENCE_NAME=MIT
POM_LICENCE_URL=http://opensource.org/licenses/MIT
POM_LICENCE_DIST=repo
SNAPSHOTS_USERNAME=snap_deploy
SNAPSHOTS_PASSWORD=snap_password
RELEASES_USERNAME=deployment
RELEASES_PASSWORD=deployment_password


POM_DEVELOPER_ID=yanlu
POM_DEVELOPER_NAME=yanlu

RELEASE_REPOSITORY_URL=http://127.0.0.1:8081/nexus/content/repositories/releases
SNAPSHOT_REPOSITORY_URL=http://127.0.0.1:8081/nexus/content/repositories/snapshots
POM_ISSUE_SYSTEM=GitHub Issues
POM_ISSUE_URL=http://127.0.0.1/android/android-common/issues

gradle-mvn-push.gradle可以直接读取上面的配置

def getReleaseRepositoryUrl() {
    return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
            : ""
}
二、配置私有仓库的用户名/密码

build.gradle 中添加私用仓库

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "http://127.0.0.1:8081/nexus/content/repositories/snapshots"
            credentials {
                //鉴权用户
                username 'dev'
                password 'dev_password'
            }
        }
    }
    ...
}