All Downloads are FREE. Search and download functionalities are using the official Maven repository.

name.remal.gradle_plugins.dsl.utils.newFileCollection.kt Maven / Gradle / Ivy

There is a newer version: 1.9.2
Show newest version
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())




© 2015 - 2024 Weber Informatics LLC | Privacy Policy