我正在尝试进行设置,以便我可以使用Gradle 版本插件 https://github.com/ben-manes/gradle-versions-plugin无需将其添加到我的所有build.gradle
files.
基于这个相关问题的答案 https://stackoverflow.com/a/32332914/90848,我尝试创建一个文件~/.gradle/init.d/50-ben-manes-versions.gradle
:
initscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
}
}
allprojects {
apply plugin: com.github.ben-manes.versions
}
如果我然后尝试调用./gradlew dependencyUpdates
在我的仓库中,我得到:
FAILURE: Build failed with an exception.
* Where:
Initialization script '~/.gradle/init.d/50-ben-manes-versions.gradle' line: 13
* What went wrong:
Could not get unknown property 'com' for root project 'project-name' of type org.gradle.api.Project.
该答案表示不要在插件名称周围使用引号,但由于这不起作用,我尝试添加引号(即:apply plugin: 'com.github.ben-manes.versions'
)。这样我得到:
FAILURE: Build failed with an exception.
* Where:
Initialization script '~/.gradle/init.d/50-ben-manes-versions.gradle' line: 13
* What went wrong:
Plugin with id 'com.github.ben-manes.versions' not found.
有没有办法从 initscript 应用 Gradle 版本插件?
顺便说一句,我正在使用 Gradle 4.3.1。