我想通过编程方式了解gradle插件的版本,以便可以从脚本中进行检查。
答案 0 :(得分:1)
您可以从Project界面使用“ buildscript”属性来访问buildScript的配置和依赖项,如下所示:
apply plugin: com.netflix.gradle.plugins.packaging.SystemPackagingPlugin
buildscript {
ext {
ospackagePluginVersion = '4.9.3'
}
repositories {
jcenter()
}
dependencies {
classpath "com.netflix.nebula:gradle-ospackage-plugin:${ospackagePluginVersion}"
}
}
println "Build script dependencies: "
buildscript.getConfigurations().getByName("classpath").getDependencies().each {
Dependency dep ->
println "Dependency : name=$dep.name in version : $dep.version"
// do something with Dependency instance..
}
这将输出:
> Configure project :
Build script dependencies:
Dependency : name=gradle-ospackage-plugin in version : 4.9.3