android模塊打包arr到github並在其他項目引用

使用的工具準備:git,android studio;

git的安裝與androidstudio的安裝方法我們不再這裏說了

1.在github上面創建repository
這裏寫圖片描述

一.首先在github上Create a new repository
二.同步github上的文件夾到本地,等下要上傳文件上去
三.打包需要上傳的模塊
1.在需要打包的模塊的bulid.gradle裏面加入

apply plugin: 'maven'
android {
    ...
    defaultConfig {
        ...
        versionCode 1
        versionName "1.0"
    }
}
ext {
    PUBLISH_GROUP_ID = 'com.xx'
    PUBLISH_ARTIFACT_ID = 'loadingdialog'
    PUBLISH_VERSION = android.defaultConfig.versionName
}
uploadArchives {
    repositories.mavenDeployer {
        def deployPath = file(getProperty('aar.deployPath'))
        repository(url: "file://${deployPath.absolutePath}")
        pom.project {
            groupId project.PUBLISH_GROUP_ID
            artifactId project.PUBLISH_ARTIFACT_ID
            version project.PUBLISH_VERSION
        }
    }
}

2.在項目根目錄的gradle.properties裏面加入

aar.deployPath=D:\\gradlelib\\xxrepo

這裏是上面需要的地址,這個是我從github上面同步下的文件夾,就是需要把打包的文件輸出到這裏,然後上傳。

3.gradle輸出arr
這裏寫圖片描述
選中需要打包的模塊,點擊upload/uploadArchives就行了,然後等待文件輸出上傳到githup
我的地址:https://github.com/baoya/xxrepo
4.通過gradle引用

複製出當前界面的連接地址,比如
https://github.com/baoya/xxrepo
對其進行修改:
https://raw.githubusercontent.com/baoya/xxrepo/master

即 github.com ——> raw.githubusercontent.com
再在末尾追加/master
表示當前要選用的是master分支的內容
在項目根目錄下

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        ...
        maven {url "https://raw.githubusercontent.com/baoya/xxrepo/master"}
    }
}

在需要用到的地方

    compile 'com.xx:loadingdialog:1.0'
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章