ianbrandt
09/15/2018, 9:23 PMconfigurations {
testImplementation {
}
}
...I get:
Script compilation error:
Line 21: testImplementation {
^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public inline fun <T : ModuleDependency> DependencyHandler.testImplementation(dependency: TypeVariable(T), dependencyConfiguration: TypeVariable(T).() -> Unit): TypeVariable(T) defined in org.gradle.kotlin.dsl
public fun DependencyHandler.testImplementation(dependencyNotation: Any): Dependency? defined in org.gradle.kotlin.dsl
public fun DependencyHandler.testImplementation(group: String, name: String, version: String? = ..., configuration: String? = ..., classifier: String? = ..., ext: String? = ...): ExternalModuleDependency defined in org.gradle.kotlin.dsl
public inline fun DependencyHandler.testImplementation(group: String, name: String, version: String? = ..., configuration: String? = ..., classifier: String? = ..., ext: String? = ..., dependencyConfiguration: ExternalModuleDependency.() -> Unit): ExternalModuleDependency defined in org.gradle.kotlin.dsl
public inline fun DependencyHandler.testImplementation(dependencyNotation: String, dependencyConfiguration: ExternalModuleDependency.() -> Unit): ExternalModuleDependency defined in org.gradle.kotlin.dsl
1 error
gildor
09/16/2018, 10:36 AMgildor
09/16/2018, 10:38 AMval testImplementation by configurations
ianbrandt
09/16/2018, 4:56 PMconfigurations {
"testImplementation" {
exclude(group = "org.foo")
}
}
configurations {
getByName("implementation") {
exclude(group = "org.foo")
}
}
configurations["testImplementation"].apply {
exclude(group = "org.foo")
}
val testImplementation by configurations
testImplementation.apply {
exclude(group = "org.foo")
}
It's just that I'm applying the Kotlin plugin declaratively in the plugins {}
block:
plugins {
kotlin("jvm") version "1.2.70"
}
...and the guide says:
Each configuration contributed by an applied plugin is also available as a member of the configurations container, so you can reference it just like any other configuration.
Knowing what configurations are available
The easiest way to find out what configurations are available is by asking your IDE for suggestions within the configurations container.
You can also use the...and thetask, which prints the Kotlin code for accessing the configurations contributed by applied plugins and provides the names for all of those accessors.:kotlinDslAccessorsReport
:kotlinDslAccessorsReport
task prints:
/**
* The 'testImplementation' configuration.
*/
val ConfigurationContainer.`testImplementation`: Configuration
get() = getByName("testImplementation")
...so I was naively expecting the testImplementation
, etc. extension properties to be statically available in the configurations {}
block (as they are in dependencies {}
):
configurations {
testImplementation {
exclude(group = "org.foo")
}
}
I see with Quick Documentation that dependencies
has a Kotlin DSL Project
extension function:
org.gradle.kotlin.dsl ProjectExtensionsKt.class
public fun Project.dependencies(
configuration: DependencyHandlerScope.() → Unit
): Unit...whereas
configurations
does not:
org.gradle.api.Project
public abstract org.gradle.api.artifacts.ConfigurationContainer getConfigurations()Is this by design, and if so, is it not possible to add similar DSL support for the
configurations {}
block as for dependencies {}
?eskatos
09/17/2018, 6:51 AMgradle/kotlin-dsl
about this?ianbrandt
09/18/2018, 3:12 AMeskatos
09/18/2018, 6:51 AM