【Android Library】项目导入到Nexus私服

1,在Android library中的Gradle中加入如下代码:

  apply plugin: 'maven'
  apply plugin: 'signing'

    signing {
        required { has("release") && gradle.taskGraph.hasTask("uploadArchives") }
        sign configurations.archives
    }

    uploadArchives {
        configuration = configurations.archives
        repositories.mavenDeployer {
            beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
            repository(url: 'http://maven.snaillove.com/nexus/content/repositories/snaillove') {//仓库地址
                authentication(userName: "admin",//用户名
                        password: "admin123")//密码
            }

            pom.project {
                name 'myhello-library'
                packaging 'aar'
                description 'none'
                url 'http://maven.snaillove.com/nexus/content/repositories/snaillove'   //仓库地址
                groupId "com.ionesmile.myhello"
                artifactId rootProject.name     //LibA
                version android.defaultConfig.versionName
            }
        }
    }

2,在Terminal中输入 “gradlew tasks”

如果是第一次执行这个命令,它需要去下载gradlew的相关支持包,所以会等待很久很久,建议在在翻墙的情况下执行下载速度会快一些。
在执行成功后,输入: “gradlew uploadArchives “,执行成功后会看到“BUILD SUCCESS”
即将文件打包成AAR上传到服务器了。

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页