gradle7.0上传github,打包maven并使用

220 阅读1分钟

1.在module.budld中添加

plugins {
    id 'maven-publish'//add
}


android {
    compileSdk 31

    defaultConfig {
        minSdk 21
        targetSdk 31
        multiDexEnabled=true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    }

     //add
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    dataBinding {
        enabled = true
    }
}


dependencies{
}

//add
afterEvaluate {
    publishing {
        publications {
            release(MavenPublication) {
                from components.release
                groupId = 'com.wyw.plugin' //groupId 随便取
                artifactId = 'wywplugin'  //artifactId 随便取
                version = '1.0'
            }
        }
    }
}

2.上传/同步至github

微信图片_20220216143843.png 点击发布

微信图片_20220216143905.png 填写信息,并提交

3,打开jitpack官网,登录自己的github账号 jitpack.io/

4.复制项目的git地址,输入在jitpack中

微信图片_20220216144145.png