From e42c5362c12bd65e37647b924fe190a9b33af29e Mon Sep 17 00:00:00 2001 From: Alex McAusland Date: Fri, 17 Apr 2020 10:39:19 +0100 Subject: [PATCH 1/3] Integrate HMCTS Java Plugin Handles configuration of checkstyle, PMD and dependency checker. See https://github.com/hmcts/gradle-java-plugin/blob/master/README.md --- build.gradle | 31 +--- config/checkstyle/checkstyle.xml | 251 ------------------------------- config/pmd/ruleset.xml | 72 --------- 3 files changed, 5 insertions(+), 349 deletions(-) delete mode 100644 config/checkstyle/checkstyle.xml delete mode 100644 config/pmd/ruleset.xml diff --git a/build.gradle b/build.gradle index c99b8e17..60db64ac 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,13 @@ plugins { id 'application' - id 'checkstyle' - id 'pmd' id 'jacoco' + /* + Applies analysis tools including checkstyle, PMD and OWASP Dependency checker. + See https://github.com/hmcts/gradle-java-plugin + */ + id 'uk.gov.hmcts.java' version '0.4.2' id 'io.spring.dependency-management' version '1.0.9.RELEASE' id 'org.springframework.boot' version '2.2.6.RELEASE' - id 'org.owasp.dependencycheck' version '5.3.2.1' id 'com.github.ben-manes.versions' version '0.28.0' id 'org.sonarqube' version '2.8' } @@ -84,21 +86,6 @@ task smoke(type: Test) { classpath = sourceSets.smokeTest.runtimeClasspath } -checkstyle { - maxWarnings = 0 - toolVersion = '8.29' - getConfigDirectory().set(new File(rootDir, 'config/checkstyle')) -} - -pmd { - toolVersion = "6.18.0" - sourceSets = [sourceSets.main, sourceSets.test, sourceSets.functionalTest, sourceSets.integrationTest, sourceSets.smokeTest] - reportsDir = file("$project.buildDir/reports/pmd") - // https://github.com/pmd/pmd/issues/876 - ruleSets = [] - ruleSetFiles = files("config/pmd/ruleset.xml") -} - jacocoTestReport { executionData(test, integration) reports { @@ -132,15 +119,7 @@ dependencyUpdates { // https://jeremylong.github.io/DependencyCheck/dependency-check-gradle/configuration.html dependencyCheck { - // Specifies if the build should be failed if a CVSS score above a specified level is identified. - // range of 0-10 fails the build, anything greater and it doesn't fail the build - failBuildOnCVSS = System.getProperty('dependencyCheck.failBuild') == 'true' ? 0 : 11 suppressionFile = 'config/owasp/suppressions.xml' - - analyzers { - // Disable scanning of .NET related binaries - assemblyEnabled = false - } } dependencyManagement { diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml deleted file mode 100644 index 25743d96..00000000 --- a/config/checkstyle/checkstyle.xml +++ /dev/null @@ -1,251 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/pmd/ruleset.xml b/config/pmd/ruleset.xml deleted file mode 100644 index 03b66c19..00000000 --- a/config/pmd/ruleset.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - HMCTS PMD rule set - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 32587c7635e38ea1d468a17ed7abc8cd2a5e5cb5 Mon Sep 17 00:00:00 2001 From: Alex McAusland Date: Fri, 17 Apr 2020 13:07:40 +0100 Subject: [PATCH 2/3] Update Readme Provide details of HMCTS Java plugin. --- README.md | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8df0a29c..2d0fa647 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ The template is a working application with a minimal setup. It contains: * application skeleton * setup script to prepare project * common plugins and libraries + * [HMCTS Java plugin](https://github.com/hmcts/gradle-java-plugin) * docker setup * swagger configuration for api documentation ([see how to publish your api documentation to shared repository](https://github.com/hmcts/reform-api-docs#publish-swagger-docs)) * code quality tools already set up @@ -29,19 +30,32 @@ The application exposes health endpoint (http://localhost:4550/health) and metri The template contains the following plugins: - * checkstyle + * HMCTS Java plugin - https://docs.gradle.org/current/userguide/checkstyle_plugin.html + Applies code analysis tools with HMCTS default settings. See the [project repository](https://github.com/hmcts/gradle-java-plugin) for details. - Performs code style checks on Java source files using Checkstyle and generates reports from these checks. - The checks are included in gradle's *check* task (you can run them by executing `./gradlew check` command). + Analysis tools include: - * pmd + * checkstyle - https://docs.gradle.org/current/userguide/pmd_plugin.html + https://docs.gradle.org/current/userguide/checkstyle_plugin.html - Performs static code analysis to finds common programming flaws. Included in gradle `check` task. + Performs code style checks on Java source files using Checkstyle and generates reports from these checks. + The checks are included in gradle's *check* task (you can run them by executing `./gradlew check` command). + * pmd + + https://docs.gradle.org/current/userguide/pmd_plugin.html + + Performs static code analysis to finds common programming flaws. Included in gradle `check` task. + + * org.owasp.dependencycheck + + https://jeremylong.github.io/DependencyCheck/dependency-check-gradle/index.html + + Provides monitoring of the project's dependent libraries and creating a report + of known vulnerable components that are included in the build. To run it + execute `gradle dependencyCheck` command. * jacoco @@ -70,13 +84,6 @@ The template contains the following plugins: Reduces the amount of work needed to create a Spring application - * org.owasp.dependencycheck - - https://jeremylong.github.io/DependencyCheck/dependency-check-gradle/index.html - - Provides monitoring of the project's dependent libraries and creating a report - of known vulnerable components that are included in the build. To run it - execute `gradle dependencyCheck` command. * com.github.ben-manes.versions From 8555fb5dba0a1eeb649793c55b68e4874da539c3 Mon Sep 17 00:00:00 2001 From: Alex McAusland Date: Mon, 20 Apr 2020 10:54:09 +0100 Subject: [PATCH 3/3] Bump gradle-java-plugin to 0.5.0 --- README.md | 6 ------ build.gradle | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2d0fa647..365d1322 100644 --- a/README.md +++ b/README.md @@ -43,12 +43,6 @@ The template contains the following plugins: Performs code style checks on Java source files using Checkstyle and generates reports from these checks. The checks are included in gradle's *check* task (you can run them by executing `./gradlew check` command). - * pmd - - https://docs.gradle.org/current/userguide/pmd_plugin.html - - Performs static code analysis to finds common programming flaws. Included in gradle `check` task. - * org.owasp.dependencycheck https://jeremylong.github.io/DependencyCheck/dependency-check-gradle/index.html diff --git a/build.gradle b/build.gradle index ad23d7b4..e3a1c1c8 100644 --- a/build.gradle +++ b/build.gradle @@ -2,10 +2,10 @@ plugins { id 'application' id 'jacoco' /* - Applies analysis tools including checkstyle, PMD and OWASP Dependency checker. + Applies analysis tools including checkstyle and OWASP Dependency checker. See https://github.com/hmcts/gradle-java-plugin */ - id 'uk.gov.hmcts.java' version '0.4.2' + id 'uk.gov.hmcts.java' version '0.5.0' id 'io.spring.dependency-management' version '1.0.9.RELEASE' id 'org.springframework.boot' version '2.2.6.RELEASE' id 'com.github.ben-manes.versions' version '0.28.0'