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

net.twisterrob.gradle.quality.tasks.FileCountReportTask.kt Maven / Gradle / Ivy

The newest version!
package net.twisterrob.gradle.quality.tasks

import net.twisterrob.gradle.common.grouper.Grouper
import net.twisterrob.gradle.dsl.reporting
import net.twisterrob.gradle.internal.safeWriteText
import net.twisterrob.gradle.quality.Violations
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.OutputFile

@CacheableTask
abstract class FileCountReportTask : BaseViolationsTask() {

	@get:OutputFile
	abstract val output: RegularFileProperty

	init {
		@Suppress("LeakingThis")
		output.convention(project.reporting.baseDirectory.file("violations.count"))
	}

	override fun processViolations(violations: Grouper.Start) {
		val count = violations.list.sumOf { it.violations.orEmpty().size }
		output.safeWriteText(count.toString())
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy