name.remal.gradle_plugins.dsl.extensions.org.gradle.api.tasks.SourceSet.kt Maven / Gradle / Ivy
package name.remal.gradle_plugins.dsl.extensions
import name.remal.Ordered
import name.remal.Services.loadServicesList
import name.remal.buildSet
import org.gradle.api.tasks.SourceSet
private val sourceSetConfigurationNameGettersFactories = loadServicesList(SourceSetConfigurationNameGettersFactory::class.java)
val SourceSet.sourceSetConfigurationNames: Set
get() = buildSet {
sourceSetConfigurationNameGettersFactories.forEach {
it.getters.forEach { getter ->
add(getter(this@sourceSetConfigurationNames))
}
}
}
private val sourceSetTaskNameGettersFactories = loadServicesList(SourceSetTaskNameGettersFactory::class.java)
val SourceSet.sourceSetTaskNames: Set
get() = buildSet {
sourceSetTaskNameGettersFactories.forEach {
it.getters.forEach { getter ->
add(getter(this@sourceSetTaskNames))
}
}
}
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
fun SourceSet.getNounName(noun: String): String = this.getTaskName(null, noun)
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
fun SourceSet.getVerbName(verb: String): String = this.getTaskName(verb, null)
fun SourceSet.forEachCorrespondingConfigurationName(other: SourceSet, action: (thisConfigurationName: String, otherConfigurationName: String) -> Unit) {
val processedNames = hashSetOf()
sourceSetConfigurationNameGettersFactories.forEach {
it.getters.forEach { getter ->
val thisConfigurationName = getter(this)
if (processedNames.add(thisConfigurationName)) {
val otherConfigurationName = getter(other)
action(thisConfigurationName, otherConfigurationName)
}
}
}
}
interface SourceSetConfigurationNameGettersFactory : Ordered {
val getters: List String>
}
interface SourceSetTaskNameGettersFactory : Ordered {
val getters: List String>
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy