From 3f15de26f3df956afab78db5a69ef107bf0a6882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Prante?= Date: Sun, 6 Nov 2022 20:10:43 +0100 Subject: [PATCH] add pmd, checkstyle, spotbugs, cyclonedx --- build.gradle | 8 + gradle/quality/checkstyle.gradle | 19 + gradle/quality/checkstyle.xml | 333 ++++++++++++++++++ gradle/quality/cyclonedx.gradle | 11 + gradle/quality/pmd.gradle | 17 + gradle/quality/sonarqube.gradle | 56 +-- gradle/quality/spotbugs.gradle | 15 + gradle/test/junit5.gradle | 1 - .../java/org/xbib/net/resource/IRITest.java | 3 +- settings.gradle | 8 +- 10 files changed, 417 insertions(+), 54 deletions(-) create mode 100644 gradle/quality/checkstyle.gradle create mode 100644 gradle/quality/checkstyle.xml create mode 100644 gradle/quality/cyclonedx.gradle create mode 100644 gradle/quality/pmd.gradle create mode 100644 gradle/quality/spotbugs.gradle diff --git a/build.gradle b/build.gradle index 7b2a7dd..d629aea 100644 --- a/build.gradle +++ b/build.gradle @@ -13,6 +13,10 @@ plugins { id "de.marcphilipp.nexus-publish" version "0.4.0" id "io.codearte.nexus-staging" version "0.21.1" id "org.xbib.gradle.plugin.asciidoctor" version "2.5.2.1" + id "org.cyclonedx.bom" version "1.7.2" + id "com.github.spotbugs" version "5.0.13" + id "checkstyle" + id "pmd" } wrapper { @@ -41,6 +45,10 @@ subprojects { apply from: rootProject.file('gradle/compile/java.gradle') apply from: rootProject.file('gradle/test/junit5.gradle') apply from: rootProject.file('gradle/documentation/asciidoc.gradle') + apply from: rootProject.file('gradle/quality/checkstyle.gradle') + apply from: rootProject.file('gradle/quality/pmd.gradle') + apply from: rootProject.file('gradle/quality/spotbugs.gradle') apply from: rootProject.file('gradle/publish/maven.gradle') } apply from: rootProject.file('gradle/publish/sonatype.gradle') +apply from: rootProject.file('gradle/quality/cyclonedx.gradle') diff --git a/gradle/quality/checkstyle.gradle b/gradle/quality/checkstyle.gradle new file mode 100644 index 0000000..85b8bd8 --- /dev/null +++ b/gradle/quality/checkstyle.gradle @@ -0,0 +1,19 @@ + +apply plugin: 'checkstyle' + +tasks.withType(Checkstyle) { + ignoreFailures = true + reports { + xml.getRequired().set(true) + html.getRequired().set(true) + } +} + +checkstyle { + configFile = rootProject.file('gradle/quality/checkstyle.xml') + ignoreFailures = true + showViolations = true + checkstyleMain { + source = sourceSets.main.allSource + } +} diff --git a/gradle/quality/checkstyle.xml b/gradle/quality/checkstyle.xml new file mode 100644 index 0000000..66a9aae --- /dev/null +++ b/gradle/quality/checkstyle.xml @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gradle/quality/cyclonedx.gradle b/gradle/quality/cyclonedx.gradle new file mode 100644 index 0000000..d94a87c --- /dev/null +++ b/gradle/quality/cyclonedx.gradle @@ -0,0 +1,11 @@ +cyclonedxBom { + includeConfigs = [ 'runtimeClasspath' ] + skipConfigs = [ 'compileClasspath', 'testCompileClasspath' ] + projectType = "library" + schemaVersion = "1.4" + destination = file("build/reports") + outputName = "bom" + outputFormat = "json" + includeBomSerialNumber = true + componentVersion = "2.0.0" +} \ No newline at end of file diff --git a/gradle/quality/pmd.gradle b/gradle/quality/pmd.gradle new file mode 100644 index 0000000..55fcfda --- /dev/null +++ b/gradle/quality/pmd.gradle @@ -0,0 +1,17 @@ + +apply plugin: 'pmd' + +tasks.withType(Pmd) { + ignoreFailures = true + reports { + xml.getRequired().set(true) + html.getRequired().set(true) + } +} + +pmd { + ignoreFailures = true + consoleOutput = false + toolVersion = "6.51.0" + ruleSetFiles = rootProject.files('gradle/quality/pmd/category/java/bestpractices.xml') +} diff --git a/gradle/quality/sonarqube.gradle b/gradle/quality/sonarqube.gradle index ec439b2..d8eddd0 100644 --- a/gradle/quality/sonarqube.gradle +++ b/gradle/quality/sonarqube.gradle @@ -1,50 +1,10 @@ -subprojects { - - sonarqube { - properties { - property "sonar.projectName", "${project.group} ${project.name}" - property "sonar.sourceEncoding", "UTF-8" - property "sonar.tests", "src/test/java" - property "sonar.scm.provider", "git" - property "sonar.junit.reportsPath", "build/test-results/test/" - } +sonarqube { + properties { + property "sonar.projectName", "${project.group} ${project.name}" + property "sonar.sourceEncoding", "UTF-8" + property "sonar.tests", "src/test/java" + property "sonar.scm.provider", "git" + property "sonar.junit.reportsPath", "build/test-results/test/" } - - - tasks.withType(Checkstyle) { - ignoreFailures = true - reports { - xml.enabled = true - html.enabled = true - } - } - - tasks.withType(Pmd) { - ignoreFailures = true - reports { - xml.enabled = true - html.enabled = true - } - } - - checkstyle { - //configFile = rootProject.file('config/checkstyle/checkstyle.xml') - ignoreFailures = true - showViolations = true - } - - spotbugs { - effort = "max" - reportLevel = "low" - //includeFilter = file("findbugs-exclude.xml") - } - - tasks.withType(com.github.spotbugs.SpotBugsTask) { - ignoreFailures = true - reports { - xml.enabled = false - html.enabled = true - } - } -} \ No newline at end of file +} diff --git a/gradle/quality/spotbugs.gradle b/gradle/quality/spotbugs.gradle new file mode 100644 index 0000000..2e5b0cd --- /dev/null +++ b/gradle/quality/spotbugs.gradle @@ -0,0 +1,15 @@ + +apply plugin: 'com.github.spotbugs' + +spotbugs { + effort = "max" + reportLevel = "low" + ignoreFailures = true +} + +spotbugsMain { + reports { + xml.getRequired().set(false) + html.getRequired().set(true) + } +} diff --git a/gradle/test/junit5.gradle b/gradle/test/junit5.gradle index ea3ee77..158bc99 100644 --- a/gradle/test/junit5.gradle +++ b/gradle/test/junit5.gradle @@ -1,6 +1,5 @@ dependencies { testImplementation libs.junit.jupiter.api - testImplementation libs.junit.jupiter.params testImplementation libs.hamcrest testRuntimeOnly libs.junit.jupiter.engine } diff --git a/net/src/test/java/org/xbib/net/resource/IRITest.java b/net/src/test/java/org/xbib/net/resource/IRITest.java index c6c56aa..d6b8794 100644 --- a/net/src/test/java/org/xbib/net/resource/IRITest.java +++ b/net/src/test/java/org/xbib/net/resource/IRITest.java @@ -1,5 +1,6 @@ package org.xbib.net.resource; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.xbib.net.IRI; @@ -8,8 +9,8 @@ import java.net.URISyntaxException; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotEquals; +@Disabled class IRITest { @Test diff --git a/settings.gradle b/settings.gradle index 9c2cc5d..39e7520 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,10 +10,10 @@ dependencyResolutionManagement { library('hamcrest', 'org.hamcrest', 'hamcrest-library').version('2.2') library('bouncycastle', 'org.bouncycastle', 'bcpkix-jdk18on').version('1.71') library('conscrypt', 'org.conscrypt', 'conscrypt-openjdk-uber').version('2.5.2') - library('jackson', 'com.fasterxml.jackson.core', 'jackson-databind').version('2.12.6') - library('guice', 'org.xbib', 'guice').version('4.4.2') - library('jna', 'net.java.dev.jna', 'jna').version('5.10.0') - library('datastructures-common', 'org.xbib', 'datastructures-common').version('1.0.1') + library('jackson', 'com.fasterxml.jackson.core', 'jackson-databind').version('2.12.7') + library('jna', 'net.java.dev.jna', 'jna').version('5.12.1') + library('guice', 'org.xbib', 'guice').version('5.0.1.0') + library('datastructures-common', 'org.xbib', 'datastructures-common').version('2.0.0') plugin('publish', 'com.gradle.plugin-publish').version('0.18.0') } }