Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gradle-plugin: treat SarifReportMergeTask as non-mandatory #1487

Merged
merged 2 commits into from
Jul 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gradle-plugin: treat SarifReportMergeTask as non-mandatory
### What's done:
* Root project might not have a task `mergeDiktatReports`
  • Loading branch information
petertrr committed Jul 29, 2022
commit bbd05b72f1bc342cfe9e8d82f43459a9bb2c77af
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.TaskExecutionException
import org.gradle.api.tasks.VerificationTask
import kotlinx.serialization.SerializationException
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
@@ -25,7 +26,7 @@ import kotlinx.serialization.json.Json
/**
* A task to merge SARIF reports produced by diktat check / diktat fix tasks.
*/
abstract class SarifReportMergeTask : DefaultTask() {
abstract class SarifReportMergeTask : DefaultTask(), VerificationTask {
/**
* Source reports that should be merged
*/
@@ -89,13 +90,13 @@ internal fun Project.configureMergeReportsTask(diktatExtension: DiktatExtension)
reportMergeTask.output.set(mergedReportFile)
}
}
val reportMergeTaskTaskProvider = rootProject.tasks.named(MERGE_SARIF_REPORTS_TASK_NAME, SarifReportMergeTask::class.java) { reportMergeTask ->
rootProject.tasks.withType(SarifReportMergeTask::class.java).configureEach { reportMergeTask ->
if (isSarifReporterActive(createReporterFlag(diktatExtension))) {
getOutputFile(diktatExtension)?.let { reportMergeTask.input.from(it) }
reportMergeTask.shouldRunAfter(tasks.withType(DiktatJavaExecTaskBase::class.java))
}
}
tasks.withType(DiktatJavaExecTaskBase::class.java).configureEach { diktatJavaExecTaskBase ->
diktatJavaExecTaskBase.finalizedBy(reportMergeTaskTaskProvider)
diktatJavaExecTaskBase.finalizedBy(rootProject.tasks.withType(SarifReportMergeTask::class.java))
}
}