【发布时间】:2020-07-22 12:05:28
【问题描述】:
我目前有一个运行良好的 init.gradle 文件:
initscript {
repositories {
jcenter()
}
dependencies {
classpath("com.github.ben-manes:gradle-versions-plugin:+")
}
}
allprojects {
apply plugin: com.github.benmanes.gradle.versions.VersionsPlugin
}
现在我想转向 kotlin DSL,因为我正在处理的所有其他项目都已迁移。
所以我创建了这个:
initscript {
repositories {
jcenter()
}
dependencies {
classpath("com.github.ben-manes:gradle-versions-plugin:+")
}
}
allprojects {
apply(plugin = com.github.benmanes.gradle.versions.VersionsPlugin)
}
不幸的是,我收到以下错误:
Script compilation error:
Line 11: apply(plugin = com.github.benmanes.gradle.versions.VersionsPlugin)
^ Classifier 'VersionsPlugin' does not have a companion object, and thus must be initialized here
当我尝试将" 放在插件周围时,我收到错误:
* What went wrong:
Plugin with id 'com.github.benmanes.gradle.versions.VersionsPlugin' not found.
当我尝试时
apply<VersionsPlugin>()
我明白了:
Line 10: apply<VersionsPlugin>()
^ Unresolved reference: VersionsPlugin
当我尝试时:
apply(plugin = "com.github.ben-manes.versions")
我明白了:
* What went wrong:
Plugin with id 'com.github.ben-manes.versions' not found.
在gradle documentation 中,我刚刚找到了有关如何初始化新插件的提示,而不是如何添加现有插件。
这里有人可以帮助我吗?
【问题讨论】: