利用nexus搭建maven庫並利用AS上傳aar

1. 進入Sonatype官網下載nexusandroid

2. 安裝完成app

3. 在服務上建立新用戶和庫com.xxx.yyymaven

4. 在android studio的工程中配置gradle

  • 工程gradle加上
    allprojects {
        repositories {
            jcenter()
            mavenLocal()  // 新加
        }
    }
  • module的gradle中加入
    apply plugin: 'maven'
  • module的gradle中加入
    uploadArchives {
        repositories.mavenDeployer {
            repository(url:"http://127.0.0.1:8081/repository/com.xxx.yyy/") {
                authentication(userName:"xxx", password:"xxx")
            }
            pom.version="0.0.1"
            pom.artifactId="my-lib"
            pom.groupId="com.xxx"
        }
    }

5. AS右側選擇gradle打開窗口,雙擊module下的uploadArchives進行上傳。url

6. 在另外一個工程中的gradle中添加it

repositories {
    maven {
        url "http://127.0.0.1:8081/repository/com.xxx.yyy/"
    }
}

7. 加入io

compile 'com.xxx:my-lib:0.0.1'

8. 構建工程,這樣aar就順利導入了。module

相關文章
相關標籤/搜索