【发布时间】:2019-10-04 23:47:32
【问题描述】:
我正在编写一个自定义 gradle 插件 Foo,我想加载 org.springframework.boot 插件
进入应用 Foo 插件的项目。我可以通过这种方式加载各种其他插件,但这
特定插件不希望以相同的方式运行。
Foo build.gradle
buildscript {
ext {
springBootVersion = "2.1.3.RELEASE"
}
}
apply plugin: "groovy"
repositories {
maven { url "http://custom.repo/blah" }
}
dependencies {
implementation gradleApi()
implementation localGroovy()
implementation("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
Foo 插件
class BuildPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.repositories {
maven { url "http://custom.repo/blah" }
}
project.plugins.apply("org.springframework.boot")
}
}
项目 build.gradle
buildscript {
dependencies {
classpath files("/some/cool/path/foo-plugin.jar")
}
}
apply plugin: "com.whatever.foo-id"
项目构建输出
$ ./gradlew --stacktrace clean build
FAILURE: Build failed with an exception.
* Where:
Build file '/cool/project/location/bar/build.gradle' line: 40
* What went wrong:
A problem occurred evaluating root project 'bar'.
> Failed to apply plugin [id 'com.whatever.foo-id']
> Plugin with id 'org.springframework.boot' not found.
是否可以从插件 2 应用插件 1,其中插件 1 是类路径依赖项?
【问题讨论】:
标签: spring-boot gradle gradle-plugin spring-boot-gradle-plugin