Ren*_*cic 7 gradle gradle-plugin
我想将属性从预编译脚本插件传递到项目本身。我在buildSrc目录中预编译了脚本插件。
1 在buildSrc/gradle.properties我定义了defaultSpringBootVersion具有 值的属性2.6.3。该属性用于buildSrc/build.gradle指定org.springframework.boot插件版本。
2 同时,我希望插件本身位于将buildSrc/src/main/groovy/com.rivancic.convention-gradle-plugin.gradle其应用于项目属性:
project.ext{
springBootVersion = defaultSpringBootVersion
}
Run Code Online (Sandbox Code Playgroud)
3 如果我尝试在根项目中访问 springBootVersion 我希望它可以通过插件使用,则会收到以下错误:
An exception occurred applying plugin request [id: 'com.rivancic.convention-gradle-plugin']
> Failed to apply plugin 'com.rivancic.convention-gradle-plugin'.
> groovy.lang.MissingPropertyException: Could not get unknown property 'defaultSpringBootVersion' for object of type org.gradle.internal.extensibility.DefaultExtraPropertiesExtension.
Run Code Online (Sandbox Code Playgroud)
示例项目链接:https://github.com/rivancic/gradle-plugin-properties
在这种情况下,如何正确地将属性注入buildSrc/gradle.properties到预编译脚本插件中buildSrc/src/main/groovy/com.rivancic.convention-gradle-plugin.gradle
| 归档时间: |
|
| 查看次数: |
373 次 |
| 最近记录: |