Open feelform opened 2 years ago
Unfortunately, I don't think you can at the moment. The support is built using Groovy's method missing feature which doesn't translate correctly to the Kotlin DSL. You have two options for the time being:
The second option would leave your example looking like this:
dependencyManagement {
dependencies {
dependency("org.springframework:spring-core:${Versions.spring}") {
exclude("commons-logging:commons-logging")
}
dependency("org.springframework:spring-beans:${Versions.spring}")
dependency("org.springframework:spring-context:${Versions.spring}")
dependency("org.springframework:spring-orm:${Versions.spring}")
dependency("org.springframework:spring-test:${Versions.spring}")
}
}
As a slight aside, instead of declaring dependency management for each of Spring Framework's modules individually, you may want to consider importing org.springframework:spring-framework-bom
instead.
A workaround is to call propertyMissing
on the extension (not methodMissing
as mentioned above)
This method delegates to the private method handlerForConfiguration
.
Define some extension functions:
fun StandardDependencyManagementExtension.withConfiguration(name: String, action: Action<DependencyManagementHandler>) {
(propertyMissing(name) as? DependencyManagementHandler)?.let {
action(it)
}
}
fun StandardDependencyManagementExtension.withConfiguration(configuration: Configuration, action: Action<DependencyManagementHandler>) {
withConfiguration(configuration.name, action)
}
This enables management of dependencies by configuration object or name:
var configOne = configurations.create("configOne") {
isCanBeConsumed = false
isCanBeResolved = true
}
configurations.create("configTwo") {
isCanBeConsumed = false
isCanBeResolved = true
}
dependencyManagement {
withConfiguration(configOne) {
imports {
mavenBom("org.springframework:spring-framework-bom:6.0.4")
}
}
withConfiguration("configTwo") {
imports {
mavenBom("org.springframework:spring-framework-bom:6.0.4")
}
}
}
java-conventions.gradle.kts
https://docs.spring.io/dependency-management-plugin/docs/current-SNAPSHOT/reference/html/#working-with-managed-versions-dependency-management-task
I can't build
testImplementation
DSL in precompiled scripts. How can I usetestImplementation
likes maven test scope in dependency management?