I currently have an init.gradle file which works fine:
initscript {
repositories {
jcenter()
}
dependencies {
classpath("com.github.ben-manes:gradle-versions-plugin:+")
}
}
allprojects {
apply plugin: com.github.benmanes.gradle.versions.VersionsPlugin
}
Now I would like to move towards the kotlin DSL, as all other projects I am working on are moved over.
So I created this:
initscript {
repositories {
jcenter()
}
dependencies {
classpath("com.github.ben-manes:gradle-versions-plugin:+")
}
}
allprojects {
apply(plugin = com.github.benmanes.gradle.versions.VersionsPlugin)
}
Unfortunately I get the following error:
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
when I try to put "
around the plugin, I get the error:
* What went wrong:
Plugin with id 'com.github.benmanes.gradle.versions.VersionsPlugin' not found.
When I try
apply<VersionsPlugin>()
I get:
Line 10: apply<VersionsPlugin>()
^ Unresolved reference: VersionsPlugin
When I try:
apply(plugin = "com.github.ben-manes.versions")
I get:
* What went wrong:
Plugin with id 'com.github.ben-manes.versions' not found.
In the gradle documentation I just found a hint about how to initialize a new plugin, not how to add an existing plugin.
Anybody here who can help me?
There is a special Kotlin extension function for this
apply<VersionsPlugin>()
// or
apply(plugin = "com.github.ben-manes.versions")
UPDATE: The first option works well for me. The full content of the init.gradle.kts
file:
import com.github.benmanes.gradle.versions.VersionsPlugin
initscript {
repositories {
jcenter()
}
dependencies {
classpath("com.github.ben-manes:gradle-versions-plugin:+")
}
}
allprojects {
apply<VersionsPlugin>()
}
Usage: ./gradlew dependencyUpdates -I init.gradle.kts
The second option fails indeed, sorry. The reason is not clear to me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.