Android 开发

创建lib上传到maven

2021-07-22  本文已影响0人  小领袖

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
    }
}


上一篇下一篇

猜你喜欢

热点阅读