我正在尝试设置一些东西,以便我可以使用 Gradle版本插件,而无需将其添加到所有
根据这个相关问题的答案,我尝试创建一个文件
如果我在我的代码库中尝试调用
那个答案说插件名称不需要加引号,但是由于这并没有起作用,我尝试添加引号(例如:
build.gradle
文件中。根据这个相关问题的答案,我尝试创建一个文件
~/.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 Versions插件?
顺便说一下,我正在使用Gradle 4.3.1。
com.github.ben-manes.versions
没有被引号包围。当您应用这样的插件时,您是通过 ID 应用它的。 - mkobit