如何从另一个模块应用插件
how to apply plugin from another module
我有两个模块 app 和 lib。
我在 lib 模块中添加了一个名为 plugin.gradle
的单独文件,其中包含如下所示的插件
apply plugin: TestPlugin
class TestPlugin implements Plugin<Project>{
@Override
void apply(Project project) {
project.task("test"){
doLast {
println "testing"
}
}
}
}
为了在 lib build.gradle 模块中应用此插件,我添加了以下内容,效果非常好
apply from: 'plugin.gradle'
但是我不知道如何将这个插件应用到另一个模块(app 模块)
apply from: "${project(':yourlib').projectDir}/file.gradle"
其中 yourlib
是包含 file.gradle
的模块
我有两个模块 app 和 lib。
我在 lib 模块中添加了一个名为 plugin.gradle
的单独文件,其中包含如下所示的插件
apply plugin: TestPlugin
class TestPlugin implements Plugin<Project>{
@Override
void apply(Project project) {
project.task("test"){
doLast {
println "testing"
}
}
}
}
为了在 lib build.gradle 模块中应用此插件,我添加了以下内容,效果非常好
apply from: 'plugin.gradle'
但是我不知道如何将这个插件应用到另一个模块(app 模块)
apply from: "${project(':yourlib').projectDir}/file.gradle"
其中 yourlib
是包含 file.gradle