一、将自定义 Gradle 插件上传到远程仓库中
Android Gradle 插件 也是一种 自定义的 Gradle 插件 , 该插件被上传到 jcenter / google / mavenCentral 远程仓库 中进行存储 , 在 Android Studio 工程的根目录中的 build.gradle 构建脚本中 , 通过如下方式将 自定义插件 引入 Android 工程 ;
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
二、创建自定义插件类型模块 ( Java or Kotlin Library )
选择 " 菜单栏 / New / New Module… " 选项 ,
在 " Create New Module " 对话框中 , 选择 创建 " Java or Kotlin Library " 类型的依赖库 ;