Open wilkinsona opened 7 years ago
Hello there! Any progress here?
No, sorry. Is there anything in particular that you'd like to do with Kotlin that isn't possible at the moment?
Well, I was working around Scala issue (#96, where this plugin overrides zinc
configuration that should not be touched, Scala compiler uses another version of scala-library
) by filtering which configurations are managed by this plugin. Since I was writing this code in Kotlin DSL, I was unable to access configurations
fake method. I used methodMissing
as workaround:
fun DependencyManagementExtension.forConfigurations(vararg configurations: Configuration, block: DependencyManagementConfigurer.() -> Unit) {
// Spring does not provide better api yet
this as StandardDependencyManagementExtension // ensure we are in root block
methodMissing("configurations", arrayOf(*configurations, delegateClosureOf(block)))
}
// Used as:
val c = configurations.filterNot { /* ... */ }.toTypedArray()
configure<DependencyManagementExtension> { // It just means `dependecyManagement {` for plugins without Kotlin DSL support
forConfigurations(*c) {
imports { /*...*/ }
dependencies { /*...*/ }
}
}
Adding explicit methods, while even not supporting typesafe Kotlin DSL, would help a lot and make code clearer. I agree that Groovy code like
dependencyManagement {
compile {
}
}
looks very cool, but I would prefer to have configurations
method not via methodMissing
.
The parts that use Groovy's
methodMissing
andpropertyMissing
are inaccessible (as far as I can determine) when using Kotlin. Supporting them will probably require formalising the API and providing some non-dynamic alternatives.