com.avito.android.check.ownersip.CheckOwnersPresentTask.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of code-ownership Show documentation
Show all versions of code-ownership Show documentation
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())
}
}