gradle-karaf-plugin
gradle-karaf-plugin copied to clipboard
Please consider migrating from Closure to Action<T> in API
See: https://discuss.gradle.org/t/in-general-would-action-not-configuration-closures-be-the-first-choice/7069/2?u=vlsi
The current API is very awkward for using with both Kotlin and Java.
Here's an example of generating a feature with Kotlin:
karaf {
features.apply {
xsdVersion = "1.5.0"
feature(closureOf<com.github.lburgazzoli.gradle.plugin.karaf.features.model.FeatureDescriptor> {
name = "postgresql"
description = "PostgreSQL JDBC driver karaf feature"
version = project.version.toString()
details = "Java JDBC 4.2 (JRE 8+) driver for PostgreSQL database"
feature("transaction-api")
includeProject = true
bundle(project.group.toString(), closureOf<com.github.lburgazzoli.gradle.plugin.karaf.features.model.BundleDescriptor> {
wrap = false
})
configuration("karafFeatures")
})
}
}
There are at least three issues here:
-
features(Closure)
. I workaround that thanks to Kotlin's.apply {
which executes a block with a given receiver -
feature(Closure)
-
bundle(String, Closure)
2&3 do not have a sane workaround :(
AFAIK, the current Gradle allows us to use Action<T>
transparently in Java, Groovy, and Kotlin, and it is the way to go.
PS. It would recommend migrating the code to Kotlin as well, but, well, that's up to you 😉