name.remal.gradle_plugins.dsl.extensions.org.gradle.api.NamedDomainObjectCollection.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-plugins-kotlin-dsl Show documentation
Show all versions of gradle-plugins-kotlin-dsl Show documentation
Remal Gradle plugins: gradle-plugins-kotlin-dsl
package name.remal.gradle_plugins.dsl.extensions
import org.gradle.api.DomainObjectCollection
import org.gradle.api.NamedDomainObjectCollection
operator fun NamedDomainObjectCollection.get(type: Class): NamedDomainObjectCollection = withType(type)
operator fun NamedDomainObjectCollection<*>.contains(name: String): Boolean = findByName(name) != null
operator fun NamedDomainObjectCollection.get(name: String): T = getByName(name)
operator fun NamedDomainObjectCollection.get(type: Class, name: String): S = withType(type).getByName(name)
fun NamedDomainObjectCollection.all(name: String, configureAction: (T) -> Unit) = all {
if (name == namer.determineName(it)) {
configureAction(it)
}
}
fun NamedDomainObjectCollection.all(nameProviders: DomainObjectCollection, nameGetter: (nameProvider: N) -> String, configureAction: (T) -> Unit) = all {
nameProviders.all { nameProvider ->
val name = nameGetter(nameProvider)
if (name == namer.determineName(it)) {
configureAction(it)
}
}
}
fun NamedDomainObjectCollection.all(type: Class, name: String, configureAction: (S) -> Unit) = withType(type).all(name, configureAction)
fun NamedDomainObjectCollection.all(type: Class, nameProviders: DomainObjectCollection, nameGetter: (nameProvider: N) -> String, configureAction: (S) -> Unit) = withType(type).all(nameProviders, nameGetter, configureAction)
fun NamedDomainObjectCollection.forEach(name: String, configureAction: (T) -> Unit) = forEach {
if (name == namer.determineName(it)) {
configureAction(it)
}
}
fun NamedDomainObjectCollection.forEach(nameProviders: DomainObjectCollection, nameGetter: (nameProvider: N) -> String, configureAction: (T) -> Unit) = forEach {
nameProviders.forEach { nameProvider ->
val name = nameGetter(nameProvider)
if (name == namer.determineName(it)) {
configureAction(it)
}
}
}
fun NamedDomainObjectCollection.forEach(type: Class, name: String, configureAction: (S) -> Unit) = withType(type).forEach(name, configureAction)
@Suppress("MaxLineLength")
fun NamedDomainObjectCollection.forEach(type: Class, nameProviders: DomainObjectCollection, nameGetter: (nameProvider: N) -> String, configureAction: (S) -> Unit) = withType(type).forEach(nameProviders, nameGetter, configureAction)