From 5a35d608ea5f89a8ed456f50fd257bf19156afff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Prante?= Date: Fri, 14 Apr 2023 18:59:28 +0200 Subject: [PATCH] update gradle build --- build.gradle | 21 +- gradle/documentation/asciidoc.gradle | 21 -- .../maven.gradle} | 19 +- gradle/publish/sonatype.gradle | 12 + gradle/publishing/sonatype.gradle | 11 - gradle/quality/checkstyle.gradle | 19 + gradle/quality/checkstyle.xml | 333 ++++++++++++++++++ gradle/quality/cyclonedx.gradle | 11 + gradle/quality/pmd.gradle | 17 + gradle/quality/sonarqube.gradle | 10 + gradle/quality/spotbugs.gradle | 15 + settings.gradle | 4 +- .../z3950/client/jdk/test/LVIZClientTest.java | 2 + 13 files changed, 441 insertions(+), 54 deletions(-) rename gradle/{publishing/publication.gradle => publish/maven.gradle} (78%) create mode 100644 gradle/publish/sonatype.gradle delete mode 100644 gradle/publishing/sonatype.gradle 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/sonarqube.gradle create mode 100644 gradle/quality/spotbugs.gradle diff --git a/build.gradle b/build.gradle index 3bfbef1..1b9f272 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,13 @@ + plugins { - id "de.marcphilipp.nexus-publish" version "0.4.0" - id "io.codearte.nexus-staging" version "0.21.1" + id "checkstyle" + id "pmd" + id 'maven-publish' + id 'signing' + id "io.github.gradle-nexus.publish-plugin" version "1.3.0" + id "com.github.spotbugs" version "5.0.14" + id "org.cyclonedx.bom" version "1.7.2" + id "org.xbib.gradle.plugin.asciidoctor" version "2.5.2.2" } wrapper { @@ -25,8 +32,14 @@ ext { subprojects { apply from: rootProject.file('gradle/ide/idea.gradle') + apply from: rootProject.file('gradle/repositories/maven.gradle') apply from: rootProject.file('gradle/compile/java.gradle') apply from: rootProject.file('gradle/test/junit5.gradle') - apply from: rootProject.file('gradle/publishing/publication.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/publishing/sonatype.gradle') +apply from: rootProject.file('gradle/publish/sonatype.gradle') +apply from: rootProject.file('gradle/quality/cyclonedx.gradle') diff --git a/gradle/documentation/asciidoc.gradle b/gradle/documentation/asciidoc.gradle index ae6940e..2e27edb 100644 --- a/gradle/documentation/asciidoc.gradle +++ b/gradle/documentation/asciidoc.gradle @@ -1,26 +1,5 @@ apply plugin: 'org.xbib.gradle.plugin.asciidoctor' -configurations { - asciidoclet -} - -dependencies { - asciidoclet "org.asciidoctor:asciidoclet:${project.property('asciidoclet.version')}" -} - -/* -javadoc { - options.docletpath = configurations.asciidoclet.files.asType(List) - options.doclet = 'org.asciidoctor.Asciidoclet' - //options.overview = "src/docs/asciidoclet/overview.adoc" - options.addStringOption "-base-dir", "${projectDir}" - options.addStringOption "-attribute", - "name=${project.name},version=${project.version},title-link=https://github.com/xbib/${project.name}" - configure(options) { - noTimestamp = true - } -}*/ - asciidoctor { attributes 'source-highlighter': 'coderay', toc: 'left', diff --git a/gradle/publishing/publication.gradle b/gradle/publish/maven.gradle similarity index 78% rename from gradle/publishing/publication.gradle rename to gradle/publish/maven.gradle index 2e2b2c0..cb5a714 100644 --- a/gradle/publishing/publication.gradle +++ b/gradle/publish/maven.gradle @@ -1,13 +1,12 @@ -apply plugin: "de.marcphilipp.nexus-publish" - publishing { publications { - mavenJava(MavenPublication) { + "${project.name}"(MavenPublication) { from components.java artifact sourcesJar artifact javadocJar pom { + artifactId = project.name name = project.name description = rootProject.ext.description url = rootProject.ext.url @@ -49,18 +48,6 @@ publishing { if (project.hasProperty("signing.keyId")) { apply plugin: 'signing' signing { - sign publishing.publications.mavenJava - } -} - -if (project.hasProperty("ossrhUsername")) { - nexusPublishing { - repositories { - sonatype { - username = project.property('ossrhUsername') - password = project.property('ossrhPassword') - packageGroup = "org.xbib" - } - } + sign publishing.publications."${project.name}" } } diff --git a/gradle/publish/sonatype.gradle b/gradle/publish/sonatype.gradle new file mode 100644 index 0000000..02744cd --- /dev/null +++ b/gradle/publish/sonatype.gradle @@ -0,0 +1,12 @@ + +if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) { + nexusPublishing { + repositories { + sonatype { + username = project.property('ossrhUsername') + password = project.property('ossrhPassword') + packageGroup = "org.xbib" + } + } + } +} diff --git a/gradle/publishing/sonatype.gradle b/gradle/publishing/sonatype.gradle deleted file mode 100644 index e1813f3..0000000 --- a/gradle/publishing/sonatype.gradle +++ /dev/null @@ -1,11 +0,0 @@ - -if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) { - - apply plugin: 'io.codearte.nexus-staging' - - nexusStaging { - username = project.property('ossrhUsername') - password = project.property('ossrhPassword') - packageGroup = "org.xbib" - } -} 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 new file mode 100644 index 0000000..d8eddd0 --- /dev/null +++ b/gradle/quality/sonarqube.gradle @@ -0,0 +1,10 @@ + +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/" + } +} 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/settings.gradle b/settings.gradle index 107d5f4..3c1637d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,10 +2,10 @@ dependencyResolutionManagement { versionCatalogs { libs { version('gradle', '7.5.1') - version('groovy', '4.0.7') + version('groovy', '4.0.11') version('junit', '5.9.2') version('junit4', '4.13.2') - version('netty', '4.1.89.Final') + version('netty', '4.1.90.Final') library('junit-jupiter-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit') library('junit-jupiter-params', 'org.junit.jupiter', 'junit-jupiter-params').versionRef('junit') library('junit-jupiter-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit') diff --git a/z3950-client-jdk/src/test/java/org/xbib/z3950/client/jdk/test/LVIZClientTest.java b/z3950-client-jdk/src/test/java/org/xbib/z3950/client/jdk/test/LVIZClientTest.java index 7d3e8f6..f427c68 100644 --- a/z3950-client-jdk/src/test/java/org/xbib/z3950/client/jdk/test/LVIZClientTest.java +++ b/z3950-client-jdk/src/test/java/org/xbib/z3950/client/jdk/test/LVIZClientTest.java @@ -1,5 +1,6 @@ package org.xbib.z3950.client.jdk.test; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.xbib.z3950.client.jdk.JDKZClient; import org.xbib.z3950.common.operations.SortOperation; @@ -14,6 +15,7 @@ class LVIZClientTest { private static final Logger logger = Logger.getLogger(LVIZClientTest.class.getName()); + @Disabled @Test void testLVI() { String query = "@attr 1=4 @attr 4=6 \"Köln strafrecht\"";