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

com.avito.android.check.ownersip.CheckOwnersPresentTask.kt Maven / Gradle / Ivy

Go to download

Collection of infrastructure libraries and gradle plugins of Avito Android project

The newest version!
package com.avito.android.check.ownersip

import com.avito.android.model.Owner
import org.gradle.api.DefaultTask
import org.gradle.api.file.ProjectLayout
import org.gradle.api.file.RegularFile
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.provider.SetProperty
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import javax.inject.Inject

@CacheableTask
public abstract class CheckOwnersPresentTask @Inject constructor(
    projectLayout: ProjectLayout
) : DefaultTask() {

    @get:Input
    public abstract val owners: SetProperty

    @get:Input
    public abstract val emptyOwnersErrorMessage: Property

    @get:Input
    public abstract val projectPath: Property

    @get:OutputFile
    public val outputFile: Provider =
        projectLayout.buildDirectory.file("owners-present.output")

    @TaskAction
    public fun check() {
        val codeOwners = owners.get()
        if (codeOwners.isEmpty()) {
            val emptyOwnersMessage = emptyOwnersErrorMessage.get()
            throw IllegalStateException(emptyOwnersMessage.format(projectPath.get()))
        }
        outputFile.get().asFile.writeText("Owners: " + codeOwners.joinToString())
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy