1、下载配置nexus,创建对应仓库

2、Maven接入

在Android工程根目录build.gradle中配置

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven{
            url \'http://localhost:8081/repository/imooc-releases/\'
            credentials{
                username \'admin\'
                password \'admin123\'
            }
        }
        maven{
            url \'http://localhost:8081/repository/imooc-snapshots/\'
            credentials{
                username \'admin\'
                password \'admin123\'
            }
        }
    }
    dependencies {
        classpath \'com.android.tools.build:gradle:3.2.0\'
        
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven{
            url \'http://localhost:8081/repository/imooc-releases/\'
            credentials{
                username \'admin\'
                password \'admin123\'
            }
        }
        maven{
            url \'http://localhost:8081/repository/imooc-snapshots/\'
            credentials{
                username \'admin\'
                password \'admin123\'
            }
        }
    }
}

  

3、在gradle.properties中配置属性

NEXUS_REPOSITORY_URL=http://localhost:8081/repository/imooc-snapshots/
# maven仓库组织名
POM_GROUPID=com.imooc.android
POM_PACKAGING=aar
NEXUS_USERNAME=admin
NEXUS_PASSWORD=admin123

 

4、上传maven配置

在库工程build.gradle, 添加maven plugin,定义变量

apply plugin: \'maven\'

def pomVersionName = \'1.0.0-SNAPSHOT\'
def pomName = this.getName()
def pomDescription = \'the audio library for all project\'
def versionString = \'1.0\'
def versionNumber = 1

 

配置上传脚本

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: NEXUS_REPOSITORY_URL) {
                authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)
            }
            pom.project {
                name pomName
                version pomVersionName
                description pomDescription
                artifactId pomVersionName
                groupId POM_GROUPID
                packaging POM_PACKAGING
            }
        }
    }
}

  

 

版权声明:本文为kyun原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/kyun/p/12214652.html