Android studio 发布已有aar到远程maven仓库

在project的build.gradle中添加

buildscript{
	repositories{
		classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
	}
}

AS中新建module,在module的build.gradle中复制以下代码

apply plugin: 'java-library'
apply plugin: 'maven'
apply plugin: 'signing'


// 获取仓库url
def getRepositoryUrl() {

    def mavenReleasePath = "xxx"//项目名称路径
    //Nexus仓库BASE URL
    def BASE_MAVEN_REPO_URL = "http://xxx.xxx.xxx/"

    return BASE_MAVEN_REPO_URL + mavenReleasePath + "/";

}

// 进行数字签名
signing {
    required { gradle.taskGraph.hasTask("uploadArchives") }
    sign configurations.archives
}

//发布
uploadArchives {
    repositories {
        mavenDeployer {
            beforeDeployment {
                MavenDeployment deployment -> signing.signPom(deployment)
            }
            repository(url: getRepositoryUrl()) {
                authentication(userName: xxx, password: xxx) // maven授权信息
            }
            pom.project {
                version "1.0.0"
                artifactId "xxx"
                groupId "com.xx.xxx"
                description "xxx"
            }
        }
    }
}

//兼容中文字符
allprojects {
    tasks.withType(Javadoc) {
        options {
            encoding "UTF-8"
            charSet 'UTF-8'
            links "http://docs.oracle.com/javase/7/docs/api"
        }
    }
}

//兼容中文字符
tasks.withType(JavaCompile) {
    options.encoding = "UTF-8"
    options.compilerArgs << "-Xlint:unchecked"
}

tasks.withType(Javadoc) {
    options.addStringOption('Xdoclint:none', '-quiet')
    options.addStringOption('encoding', 'UTF-8')
    options.addStringOption('charSet', 'UTF-8')
}
def coreAarFile = file('../xxx/libs/xxxx-1.0.0.aar')//aar路径
artifacts {
    archives coreAarFile
}

你可能感兴趣的:(#,gradle)