From e6684d19aa96611740251face228df32227c9a7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Vonheiden?= <bjoern.vonheiden@hotmail.de> Date: Wed, 13 May 2020 19:03:00 +0200 Subject: [PATCH] Enable code quality tools in gradle for all subprojects Enables the execution of the code quality tools in the subprojects and configures them in a central place. --- build.gradle | 94 +++++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/build.gradle b/build.gradle index 8adda140c..1375739ca 100644 --- a/build.gradle +++ b/build.gradle @@ -18,16 +18,13 @@ allprojects { // Plugins for subprojects subprojects { apply plugin: 'application' + apply plugin: 'checkstyle' + apply plugin: 'pmd' + apply plugin: 'com.github.spotbugs' } apply plugin: 'java-library' -apply plugin: 'pmd' -apply plugin: 'checkstyle' -apply plugin: 'com.github.spotbugs' - - - sourceCompatibility = "1.11" targetCompatibility = "1.11" @@ -60,30 +57,6 @@ dependencies { // Use JUnit test framework testImplementation 'junit:junit:4.12' } - -pmd { - ruleSets = [] // Gradle requires to clean the rule sets first - ruleSetFiles = files("config/pmd.xml") - ignoreFailures = false - toolVersion = "6.7.0" -} - -checkstyle { - configDir = file("config") - configFile = file("config/checkstyle.xml") - maxWarnings = 0 - ignoreFailures = false - toolVersion = "8.12" -} - -spotbugs { - excludeFilter = file("config/spotbugs-exclude-filter.xml") - reportLevel = "low" - effort = "max" - ignoreFailures = false - toolVersion = '3.1.7' -} - // Per default XML reports for SpotBugs are generated // Include this to generate HTML reports tasks.withType(com.github.spotbugs.SpotBugsTask) { @@ -94,28 +67,57 @@ tasks.withType(com.github.spotbugs.SpotBugsTask) { } } -task checkstyle { - group 'Quality Assurance' - description 'Run Checkstyle' +// Subprojects quality tools tasks +subprojects { + task pmd { + group 'Quality Assurance' + description 'Run PMD' + + dependsOn 'pmdMain' + dependsOn 'pmdTest' + } - dependsOn 'checkstyleMain' - dependsOn 'checkstyleTest' -} + task checkstyle { + group 'Quality Assurance' + description 'Run Checkstyle' -task pmd { - group 'Quality Assurance' - description 'Run PMD' + dependsOn 'checkstyleMain' + dependsOn 'checkstyleTest' + } + + task spotbugs { + group 'Quality Assurance' + description 'Run SpotBugs' - dependsOn 'pmdMain' - dependsOn 'pmdTest' + dependsOn 'spotbugsMain' + dependsOn 'spotbugsTest' + } } -task spotbugs { - group 'Quality Assurance' - description 'Run SpotBugs' +// Subprojects quality tools configuration +subprojects { + pmd { + ruleSets = [] // Gradle requires to clean the rule sets first + ruleSetFiles = files("$rootProject.projectDir/config/pmd.xml") + ignoreFailures = false + toolVersion = "6.7.0" + } - dependsOn 'spotbugsMain' - dependsOn 'spotbugsTest' + checkstyle { + configDirectory = file("$rootProject.projectDir/config") + configFile = file("$rootProject.projectDir/config/checkstyle.xml") + maxWarnings = 0 + ignoreFailures = false + toolVersion = "8.12" + } + + spotbugs { + excludeFilter = file("$rootProject.projectDir/config/spotbugs-exclude-filter.xml") + reportLevel = "low" + effort = "max" + ignoreFailures = false + toolVersion = '3.1.7' + } } allprojects { -- GitLab