name.remal.gradle_plugins.dsl.utils.newFileCollection.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.utils
import org.gradle.api.file.FileCollection
import org.gradle.api.internal.file.AbstractFileCollection
import java.io.File
fun newFileCollection(filesFactory: () -> Iterable): FileCollection {
val filesSet: Set by lazy { filesFactory().toSet() }
return object : AbstractFileCollection() {
override fun getFiles() = filesSet
override fun getBuildDependencies() = EmptyTaskDependencies
override fun getDisplayName() = "file collection"
override fun equals(other: Any?) = other is FileCollection && other.files == files
override fun hashCode() = 1 + files.hashCode()
}
}
fun newFileCollection(files: Iterable) = newFileCollection({ files })
fun newFileCollection(vararg files: File) = newFileCollection(files.toList())