Carsten L
11/24/2017, 9:33 AMDomainObjectCollection.withType
in Kotlin DSL?
my example when writing a Plugin :
project.run {
repositories.withType(MavenArtifactRepository::class.java) {
// I want to access the typed repo
dostuff( this)
}
}
what Building gives me:
Error:(22, 44) Kotlin: Type mismatch: inferred type is Project but MavenArtifactRepository was expected
I tried this@withType
but that just yields: ‘this’ is not defined in this context.
Can anyone hint me how to do this?Czar
11/24/2017, 10:14 AMproject.run {
repositories.withType<MavenArtifactRepository> {
doStuffTo(this)
}
}
::class.java
when a reified generic is available, like in this instance. Generic looks far cleaner and gives you type inference.Carsten L
11/24/2017, 10:57 AM