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

app.softwork.kotlin.actions.CheckFileTask.kt Maven / Gradle / Ivy

The newest version!
package app.softwork.kotlin.actions

import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.api.tasks.Input
import org.gradle.work.DisableCachingByDefault
import java.io.File

@DisableCachingByDefault(because = "Not worth caching")
abstract class CheckFileTask : DefaultTask() {
    @get:Input
    abstract val expected: Property

    @get:InputFile
    @get:PathSensitive(PathSensitivity.NONE)
    abstract val actual: RegularFileProperty

    @get:Input
    internal abstract val copyTaskPath: Property

    @TaskAction
    fun checkContent() {
        val expected = File(expected.get())
        require(expected.exists()) {
            "$expected not found. Did you forget to call ${copyTaskPath.get()}?"
        }
        require(expected.readText() == actual.asFile.get().readText()) {
            "$expected does not match ${actual.asFile.get()}. Did you forget to call ${copyTaskPath.get()}?"
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy