Gradle7.0引入plugin
在gradle7.0引入使用plugin已经发生了更改.
举例使用
7.0 之前
1.引入方式是在 project的build.gradle中这样配置
buildscript {
repositories {
maven { url'xxxx' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
//插件引入
classpath "com.agent.android:agent:1.0.1"
}
}
2.在module的build.gradle中使用
apply plugin: 'agent'
7.0 之后
1.引入方式是在 settings.gradle中这样配置
pluginManagement {
//构建依赖库仓配置
repositories {
maven { url 'xxxxxxxx' }
gradlePluginPortal()
mavenCentral()
google()
}
resolutionStrategy {
eachPlugin {
println("构建使用插件" + requested.id.id)
//判断当前是否要使用这个插件,如果使用则引入插件
if (requested.id.id == 'agent'){
useModule("com.agent.android:agent:1.0.1")
}
}
}
}
2.在module的build.gradle中使用
apply plugin: 'agent'