Created
January 17, 2020 16:27
-
-
Save volodia-chornenkyy/f1e1c9e00ccd36aa6e23e040869b5b10 to your computer and use it in GitHub Desktop.
Gradle task which gathers all Detekt reports from the subprojects and put it in the one folder "$rootDir/reports/detekt". It simplifies CI process a bit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task detektGrabSubprojectsReports { | |
group = "Verification" | |
def detektSingleReportFolder = "$rootDir/reports/detekt" | |
def detektGeneralFolder = new File(detektSingleReportFolder) | |
detektGeneralFolder.mkdirs(); | |
subprojects.findAll { subproject -> | |
def projectReportDir = "$subproject.buildDir/reports" | |
def detektReportFiles = [ | |
"detekt.xml", | |
"detekt.html" | |
] | |
def detektReport = new File("$projectReportDir/${detektReportFiles[0]}") | |
if (detektReport.exists()) { | |
println "Detekt report for $subproject is available." | |
def subprojectReportDir = new File("$detektSingleReportFolder/${subproject.name}") | |
subprojectReportDir.mkdirs() | |
detektReportFiles.each { name -> | |
println name | |
def src = new File("$projectReportDir/$name") | |
def target = new File("$subprojectReportDir/$name") | |
target.createNewFile() | |
target.write(src.text) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
kotlin version. I had to change (
val projectReportDir = "${subproject.buildDir}/reports/detekt"
) for my project as the reports are in a detekt dir.