gpt4 book ai didi

spring-boot - Gradle插件将org.springframework.boot加载到项目中

转载 作者:行者123 更新时间:2023-12-03 05:35:57 24 4
gpt4 key购买 nike

我正在编写一个自定义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插件将org.springframework.boot加载到项目中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56189891/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com