创建lib上传到maven

local.properties配置

maven.url=http\://repo.cho.cn/nexus/content/repositories/releases/
maven.user=admin
maven.password=12345677
version=0.0.0.1

build.gradle 配置

uploadArchives {
    // 读取本地配置文件
    Properties properties = new Properties()
    properties.load(project.rootProject.file('gradle.properties').newInputStream())
    def userName = properties.getProperty('maven.user')
    def password = properties.getProperty('maven.password')
    def mavenUrl = properties.getProperty('maven.url')
    def libVersion = properties.getProperty('version')
    repositories {
        mavenLocal()
        repositories.mavenDeployer {
            repository(url: mavenUrl) {
                authentication(userName: userName, password: password)
            }
            pom.project {
                groupId 'com.cho.lib.analysis'
                artifactId 'analysis'
                version libVersion
                packaging 'aar'
            }
        }
    }

    task androidSourcesJar(type: Jar) {
        classifier = 'sources'
        from android.sourceSets.main.java.sourceFiles
    }
    artifacts {
        archives androidSourcesJar
    }
}


你可能感兴趣的:(创建lib上传到maven)