update to Gradle 8.1.1, block long running tests, block tests with locked ports

This commit is contained in:
Jörg Prante 2023-05-26 16:16:48 +02:00
parent 19f02c350d
commit 47972552c8
31 changed files with 269 additions and 145 deletions

View file

@ -1,6 +1,12 @@
plugins { plugins {
id "de.marcphilipp.nexus-publish" version "0.4.0" id "checkstyle"
id "io.codearte.nexus-staging" version "0.21.1" 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"
} }
wrapper { wrapper {
@ -13,10 +19,10 @@ ext {
name = 'oai' name = 'oai'
description = 'Open Archive Initiative library for Java' description = 'Open Archive Initiative library for Java'
inceptionYear = '2016' inceptionYear = '2016'
url = 'https://github.com/' + user + '/' + name url = 'https://xbib.org/' + user + '/' + name
scmUrl = 'https://github.com/' + user + '/' + name scmUrl = 'https://xbib.org/' + user + '/' + name
scmConnection = 'scm:git:git://github.com/' + user + '/' + name + '.git' scmConnection = 'scm:git:git://xbib.org/' + user + '/' + name + '.git'
scmDeveloperConnection = 'scm:git:ssh://git@github.com:' + user + '/' + name + '.git' scmDeveloperConnection = 'scm:git:ssh://forgejo@xbib.org:' + user + '/' + name + '.git'
issueManagementSystem = 'Github' issueManagementSystem = 'Github'
issueManagementUrl = ext.scmUrl + '/issues' issueManagementUrl = ext.scmUrl + '/issues'
licenseName = 'The Apache License, Version 2.0' licenseName = 'The Apache License, Version 2.0'
@ -24,11 +30,14 @@ ext {
} }
subprojects { subprojects {
apply plugin: 'java-library'
apply from: rootProject.file('gradle/ide/idea.gradle') 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/compile/java.gradle')
apply from: rootProject.file('gradle/test/junit5.gradle') apply from: rootProject.file('gradle/test/junit5.gradle')
apply from: rootProject.file('gradle/publishing/publication.gradle') apply from: rootProject.file('gradle/publish/maven.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/sonatype.gradle')
apply from: rootProject.file('gradle/publishing/sonatype.gradle') apply from: rootProject.file('gradle/publish/forgejo.gradle')

View file

@ -1,7 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress checks="." files="[\\/]generated-src[\\/].*\.java$"/>
</suppressions>

View file

@ -3,6 +3,8 @@ apply plugin: 'java-library'
java { java {
modularity.inferModulePath.set(true) modularity.inferModulePath.set(true)
withSourcesJar()
withJavadocJar()
} }
compileJava { compileJava {
@ -21,18 +23,12 @@ jar {
} }
} }
task sourcesJar(type: Jar) { tasks.withType(JavaCompile) {
dependsOn classes options.compilerArgs << '-Xlint:all'
classifier 'sources' options.encoding = 'UTF-8'
from sourceSets.main.allSource
} }
task javadocJar(type: Jar) { tasks.withType(Javadoc) {
dependsOn javadoc options.addStringOption('Xdoclint:none', '-quiet')
classifier 'javadoc' options.encoding = 'UTF-8'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar, javadocJar
} }

View file

@ -0,0 +1,16 @@
if (project.hasProperty('forgeJoToken')) {
publishing {
repositories {
maven {
url 'https://xbib.org/api/packages/xbib/maven'
credentials(HttpHeaderCredentials) {
name = "Authorization"
value = "token ${project.property('forgeJoToken')}"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}
}

27
gradle/publish/ivy.gradle Normal file
View file

@ -0,0 +1,27 @@
apply plugin: 'ivy-publish'
publishing {
repositories {
ivy {
url = "https://xbib.org/repo"
}
}
publications {
ivy(IvyPublication) {
from components.java
descriptor {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
author {
name = 'Jörg Prante'
url = 'http://example.com/users/jane'
}
descriptor.description {
text = rootProject.ext.description
}
}
}
}
}

View file

@ -1,13 +1,10 @@
apply plugin: "de.marcphilipp.nexus-publish"
publishing { publishing {
publications { publications {
mavenJava(MavenPublication) { "${project.name}"(MavenPublication) {
from components.java from components.java
artifact sourcesJar
artifact javadocJar
pom { pom {
artifactId = project.name
name = project.name name = project.name
description = rootProject.ext.description description = rootProject.ext.description
url = rootProject.ext.url url = rootProject.ext.url
@ -49,16 +46,6 @@ publishing {
if (project.hasProperty("signing.keyId")) { if (project.hasProperty("signing.keyId")) {
apply plugin: 'signing' apply plugin: 'signing'
signing { signing {
sign publishing.publications.mavenJava sign publishing.publications."${project.name}"
}
}
nexusPublishing {
repositories {
sonatype {
username = project.property('ossrhUsername')
password = project.property('ossrhPassword')
packageGroup = "org.xbib"
}
} }
} }

View file

@ -0,0 +1,11 @@
if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) {
nexusPublishing {
repositories {
sonatype {
username = project.property('ossrhUsername')
password = project.property('ossrhPassword')
packageGroup = "org.xbib"
}
}
}
}

View file

@ -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"
}
}

View file

@ -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
}
}

View file

@ -9,6 +9,10 @@ page at http://checkstyle.sourceforge.net/config.html -->
<module name="Checker"> <module name="Checker">
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value=".*(Example|Test|module-info)(\$.*)?"/>
</module>
<module name="FileTabCharacter"> <module name="FileTabCharacter">
<!-- Checks that there are no tab characters in the file. <!-- Checks that there are no tab characters in the file.
--> -->
@ -56,10 +60,19 @@ page at http://checkstyle.sourceforge.net/config.html -->
<!-- Checks for out of order import statements. --> <!-- Checks for out of order import statements. -->
<property name="severity" value="warning"/> <property name="severity" value="warning"/>
<property name="groups" value="com,junit,net,org,java,javax"/> <!-- <property name="tokens" value="IMPORT, STATIC_IMPORT"/> -->
<!-- This ensures that static imports go first. --> <property name="separated" value="false"/>
<property name="option" value="top"/> <property name="groups" value="*"/>
<property name="tokens" value="STATIC_IMPORT, IMPORT"/> <!-- <property name="option" value="above"/> -->
<property name="sortStaticImportsAlphabetically" value="true"/>
</module>
<module name="CustomImportOrder">
<!-- <property name="customImportOrderRules" value="THIRD_PARTY_PACKAGE###SPECIAL_IMPORTS###STANDARD_JAVA_PACKAGE###STATIC"/> -->
<!-- <property name="specialImportsRegExp" value="^javax\."/> -->
<!-- <property name="standardPackageRegExp" value="^java\."/> -->
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="false"/>
</module> </module>
<!-- <!--
@ -71,14 +84,10 @@ page at http://checkstyle.sourceforge.net/config.html -->
<!-- Checks for Javadoc comments. --> <!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html --> <!-- See http://checkstyle.sf.net/config_javadoc.html -->
<module name="JavadocMethod"> <module name="JavadocMethod">
<property name="scope" value="protected"/> <property name="accessModifiers" value="protected"/>
<property name="severity" value="warning"/> <property name="severity" value="warning"/>
<property name="allowMissingJavadoc" value="true"/>
<property name="allowMissingParamTags" value="true"/> <property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/> <property name="allowMissingReturnTag" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
<property name="allowUndeclaredRTE" value="true"/>
</module> </module>
<module name="JavadocType"> <module name="JavadocType">
@ -184,21 +193,6 @@ page at http://checkstyle.sourceforge.net/config.html -->
--> -->
<module name="LineLength">
<!-- Checks if a line is too long. -->
<property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="128"/>
<property name="severity" value="error"/>
<!--
The default ignore pattern exempts the following elements:
- import statements
- long URLs inside comments
-->
<property name="ignorePattern"
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
default="^(package .*;\s*)|(import .*;\s*)|( *(\*|//).*https?://.*)$"/>
</module>
<module name="LeftCurly"> <module name="LeftCurly">
<!-- Checks for placement of the left curly brace ('{'). --> <!-- Checks for placement of the left curly brace ('{'). -->
@ -319,5 +313,21 @@ page at http://checkstyle.sourceforge.net/config.html -->
</module> </module>
</module> </module>
<module name="LineLength">
<!-- Checks if a line is too long. -->
<property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="128"/>
<property name="severity" value="error"/>
<!--
The default ignore pattern exempts the following elements:
- import statements
- long URLs inside comments
-->
<property name="ignorePattern"
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
default="^(package .*;\s*)|(import .*;\s*)|( *(\*|//).*https?://.*)$"/>
</module>
</module> </module>

View file

@ -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"
}

17
gradle/quality/pmd.gradle Normal file
View file

@ -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')
}

View file

@ -48,6 +48,7 @@ public abstract class Foo {
</rule> </rule>
<rule name="AccessorClassGeneration" <rule name="AccessorClassGeneration"
language="java"
since="1.04" since="1.04"
maximumLanguageVersion="10" maximumLanguageVersion="10"
message="Avoid instantiation through private constructors from outside of the constructor's class." message="Avoid instantiation through private constructors from outside of the constructor's class."
@ -109,6 +110,7 @@ public class OuterClass {
</rule> </rule>
<rule name="ArrayIsStoredDirectly" <rule name="ArrayIsStoredDirectly"
language="java"
since="2.2" since="2.2"
message="The user-supplied array ''{0}'' is stored directly." message="The user-supplied array ''{0}'' is stored directly."
class="net.sourceforge.pmd.lang.java.rule.bestpractices.ArrayIsStoredDirectlyRule" class="net.sourceforge.pmd.lang.java.rule.bestpractices.ArrayIsStoredDirectlyRule"
@ -168,6 +170,7 @@ class Foo {
</rule> </rule>
<rule name="AvoidReassigningLoopVariables" <rule name="AvoidReassigningLoopVariables"
language="java"
since="6.11.0" since="6.11.0"
message="Avoid reassigning the loop control variable ''{0}''" message="Avoid reassigning the loop control variable ''{0}''"
class="net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidReassigningLoopVariablesRule" class="net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidReassigningLoopVariablesRule"
@ -216,6 +219,7 @@ public class Foo {
</rule> </rule>
<rule name="AvoidReassigningParameters" <rule name="AvoidReassigningParameters"
language="java"
since="1.0" since="1.0"
message="Avoid reassigning parameters such as ''{0}''" message="Avoid reassigning parameters such as ''{0}''"
class="net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidReassigningParametersRule" class="net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidReassigningParametersRule"
@ -265,6 +269,7 @@ public class Foo {
</rule> </rule>
<rule name="AvoidUsingHardCodedIP" <rule name="AvoidUsingHardCodedIP"
language="java"
since="4.1" since="4.1"
message="Do not hard code the IP address ${variableName}" message="Do not hard code the IP address ${variableName}"
class="net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidUsingHardCodedIPRule" class="net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidUsingHardCodedIPRule"
@ -493,7 +498,7 @@ for (int i = 0, j = 0; i < 10; i++, j += 2) {
<property name="xpath"> <property name="xpath">
<value> <value>
<![CDATA[ <![CDATA[
//ClassOrInterfaceBodyDeclaration[MethodDeclaration/MethodDeclarator[@Image='suite']] //ClassOrInterfaceBodyDeclaration[MethodDeclaration/MethodDeclarator[@Name='suite']]
[MethodDeclaration/ResultType/Type/ReferenceType/ClassOrInterfaceType[pmd-java:typeIs('junit.framework.Test')]] [MethodDeclaration/ResultType/Type/ReferenceType/ClassOrInterfaceType[pmd-java:typeIs('junit.framework.Test')]]
[not(MethodDeclaration/Block//ClassOrInterfaceType[pmd-java:typeIs('junit.framework.JUnit4TestAdapter')])] [not(MethodDeclaration/Block//ClassOrInterfaceType[pmd-java:typeIs('junit.framework.JUnit4TestAdapter')])]
]]> ]]>
@ -535,7 +540,7 @@ public class GoodTest {
<value> <value>
<![CDATA[ <![CDATA[
//ClassOrInterfaceBodyDeclaration //ClassOrInterfaceBodyDeclaration
[MethodDeclaration/MethodDeclarator[@Image='tearDown']] [MethodDeclaration/MethodDeclarator[@Name='tearDown']]
[count(Annotation//Name[ [count(Annotation//Name[
pmd-java:typeIs('org.junit.After') pmd-java:typeIs('org.junit.After')
or pmd-java:typeIs('org.junit.jupiter.api.AfterEach') or pmd-java:typeIs('org.junit.jupiter.api.AfterEach')
@ -579,7 +584,7 @@ public class MyTest2 {
<value> <value>
<![CDATA[ <![CDATA[
//ClassOrInterfaceBodyDeclaration //ClassOrInterfaceBodyDeclaration
[MethodDeclaration/MethodDeclarator[@Image='setUp']] [MethodDeclaration/MethodDeclarator[@Name='setUp']]
[count(Annotation//Name[ [count(Annotation//Name[
pmd-java:typeIs('org.junit.Before') pmd-java:typeIs('org.junit.Before')
or pmd-java:typeIs('org.junit.jupiter.api.BeforeEach') or pmd-java:typeIs('org.junit.jupiter.api.BeforeEach')
@ -623,10 +628,10 @@ public class MyTest2 {
<value> <value>
<![CDATA[ <![CDATA[
//ClassOrInterfaceDeclaration[ //ClassOrInterfaceDeclaration[
matches(@Image, $testClassPattern) matches(@SimpleName, $testClassPattern)
or ExtendsList/ClassOrInterfaceType[pmd-java:typeIs('junit.framework.TestCase')]] or ExtendsList/ClassOrInterfaceType[pmd-java:typeIs('junit.framework.TestCase')]]
/ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration[MethodDeclaration[@Public=true()]/MethodDeclarator[starts-with(@Image, 'test')]] /ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration[MethodDeclaration[@Public=true()]/MethodDeclarator[starts-with(@Name, 'test')]]
[not(Annotation//Name[ [not(Annotation//Name[
pmd-java:typeIs('org.junit.Test') pmd-java:typeIs('org.junit.Test')
or pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest') or pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
@ -656,6 +661,7 @@ public class MyTest {
</rule> </rule>
<rule name="JUnitAssertionsShouldIncludeMessage" <rule name="JUnitAssertionsShouldIncludeMessage"
language="java"
since="1.04" since="1.04"
message="JUnit assertions should include a message" message="JUnit assertions should include a message"
class="net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitAssertionsShouldIncludeMessageRule" class="net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitAssertionsShouldIncludeMessageRule"
@ -734,6 +740,7 @@ public class MyTestCase extends TestCase {
</rule> </rule>
<rule name="JUnitTestsShouldIncludeAssert" <rule name="JUnitTestsShouldIncludeAssert"
language="java"
since="2.0" since="2.0"
message="JUnit tests should include assert() or fail()" message="JUnit tests should include assert() or fail()"
class="net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitTestsShouldIncludeAssertRule" class="net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitTestsShouldIncludeAssertRule"
@ -758,6 +765,7 @@ public class Foo extends TestCase {
</rule> </rule>
<rule name="JUnitUseExpected" <rule name="JUnitUseExpected"
language="java"
since="4.0" since="4.0"
message="In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions" message="In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions"
class="net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitUseExpectedRule" class="net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitUseExpectedRule"
@ -788,6 +796,7 @@ public class MyTest {
</rule> </rule>
<rule name="LooseCoupling" <rule name="LooseCoupling"
language="java"
since="0.7" since="0.7"
message="Avoid using implementation types like ''{0}''; use the interface instead" message="Avoid using implementation types like ''{0}''; use the interface instead"
class="net.sourceforge.pmd.lang.java.rule.bestpractices.LooseCouplingRule" class="net.sourceforge.pmd.lang.java.rule.bestpractices.LooseCouplingRule"
@ -824,6 +833,7 @@ public class Bar {
</rule> </rule>
<rule name="MethodReturnsInternalArray" <rule name="MethodReturnsInternalArray"
language="java"
since="2.2" since="2.2"
message="Returning ''{0}'' may expose an internal array." message="Returning ''{0}'' may expose an internal array."
class="net.sourceforge.pmd.lang.java.rule.bestpractices.MethodReturnsInternalArrayRule" class="net.sourceforge.pmd.lang.java.rule.bestpractices.MethodReturnsInternalArrayRule"
@ -848,6 +858,7 @@ public class SecureSystem {
<rule name="MissingOverride" <rule name="MissingOverride"
language="java"
since="6.2.0" since="6.2.0"
minimumLanguageVersion="1.5" minimumLanguageVersion="1.5"
message="The method ''{0}'' is missing an @Override annotation." message="The method ''{0}'' is missing an @Override annotation."
@ -1000,6 +1011,7 @@ class Foo {
</rule> </rule>
<rule name="PreserveStackTrace" <rule name="PreserveStackTrace"
language="java"
since="3.7" since="3.7"
message="New exception is thrown in catch block, original stack trace may be lost" message="New exception is thrown in catch block, original stack trace may be lost"
class="net.sourceforge.pmd.lang.java.rule.bestpractices.PreserveStackTraceRule" class="net.sourceforge.pmd.lang.java.rule.bestpractices.PreserveStackTraceRule"
@ -1217,6 +1229,7 @@ public class Foo {
</rule> </rule>
<rule name="UnusedImports" <rule name="UnusedImports"
language="java"
since="1.0" since="1.0"
message="Avoid unused imports such as ''{0}''" message="Avoid unused imports such as ''{0}''"
class="net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedImportsRule" class="net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedImportsRule"
@ -1489,6 +1502,7 @@ public class MyTestCase extends TestCase {
</rule> </rule>
<rule name="UseCollectionIsEmpty" <rule name="UseCollectionIsEmpty"
language="java"
since="3.9" since="3.9"
message="Substitute calls to size() == 0 (or size() != 0, size() &gt; 0, size() &lt; 1) with calls to isEmpty()" message="Substitute calls to size() == 0 (or size() != 0, size() &gt; 0, size() &lt; 1) with calls to isEmpty()"
class="net.sourceforge.pmd.lang.java.rule.bestpractices.UseCollectionIsEmptyRule" class="net.sourceforge.pmd.lang.java.rule.bestpractices.UseCollectionIsEmptyRule"
@ -1546,7 +1560,7 @@ public class Foo {
][ ][
pmd-java:typeIs('java.lang.AutoCloseable') pmd-java:typeIs('java.lang.AutoCloseable')
or or
../../PrimarySuffix/Arguments[@ArgumentCount = 1]//PrimaryPrefix[pmd-java:typeIs('java.lang.AutoCloseable')] ../../PrimarySuffix/Arguments[@Size = 1]//PrimaryPrefix[pmd-java:typeIs('java.lang.AutoCloseable')]
]] ]]
]]> ]]>
</value> </value>

View file

@ -1,6 +1,3 @@
#
# BSD-style license; for more info see http://pmd.sourceforge.net/license.html
#
rulesets.filenames=\ rulesets.filenames=\
category/java/bestpractices.xml,\ category/java/bestpractices.xml,\

View file

@ -760,7 +760,7 @@ public class HelloWorldBean {
<![CDATA[ <![CDATA[
public class Foo { public class Foo {
void bar() { void bar() {
for (;true;) true; // No Init or Update part, may as well be: while (true) for (;true;) true; // No Init or Update message, may as well be: while (true)
} }
} }
]]> ]]>

View file

@ -158,7 +158,7 @@ public class A {
message="Avoid using a branching statement as the last in a loop." message="Avoid using a branching statement as the last in a loop."
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidbranchingstatementaslastinloop"> externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidbranchingstatementaslastinloop">
<description> <description>
Using a branching statement as the last part of a loop may be a bug, and/or is confusing. Using a branching statement as the last message of a loop may be a bug, and/or is confusing.
Ensure that the usage is not a bug, or consider using another approach. Ensure that the usage is not a bug, or consider using another approach.
</description> </description>
<priority>2</priority> <priority>2</priority>
@ -1554,7 +1554,7 @@ public class Foo {
<rule name="EmptyStatementNotInLoop" <rule name="EmptyStatementNotInLoop"
language="java" language="java"
since="1.5" since="1.5"
message="An empty statement (semicolon) not part of a loop" message="An empty statement (semicolon) not message of a loop"
class="net.sourceforge.pmd.lang.rule.XPathRule" class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptystatementnotinloop"> externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptystatementnotinloop">
<description> <description>

View file

@ -0,0 +1,37 @@
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/"
}
}
tasks.withType(Pmd) {
ignoreFailures = true
reports {
xml.enabled = true
html.enabled = 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
}
}
}

View file

@ -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)
}
}

View file

@ -0,0 +1,4 @@
repositories {
mavenLocal()
mavenCentral()
}

Binary file not shown.

View file

@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

19
gradlew vendored
View file

@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@ -80,13 +80,10 @@ do
esac esac
done done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # This is normally unused
# shellcheck disable=SC2034
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@ -143,12 +140,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
case $MAX_FD in #( case $MAX_FD in #(
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command; # Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in # shell script including quotes and variable substitutions, so put them in

1
gradlew.bat vendored
View file

@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%

View file

@ -16,12 +16,12 @@ import java.util.EnumSet;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@Disabled("takes long time")
class BundeskunsthalleTest { class BundeskunsthalleTest {
private static final Logger logger = Logger.getLogger(BundeskunsthalleTest.class.getName()); private static final Logger logger = Logger.getLogger(BundeskunsthalleTest.class.getName());
@Test @Test
@Disabled("takes long time")
void testListRecords() throws Exception { void testListRecords() throws Exception {
OAIClient oaiClient = new OAIClient("https://www.bundeskunsthalle.de/cgi-bin/bib/oai-pmh"); OAIClient oaiClient = new OAIClient("https://www.bundeskunsthalle.de/cgi-bin/bib/oai-pmh");
IdentifyResponse identifyResponse = oaiClient.identify(); IdentifyResponse identifyResponse = oaiClient.identify();
@ -29,8 +29,8 @@ class BundeskunsthalleTest {
logger.log(Level.INFO, "granularity = " + granularity); logger.log(Level.INFO, "granularity = " + granularity);
DateTimeFormatter dateTimeFormatter = "YYYY-MM-DD".equals(granularity) ? DateTimeFormatter dateTimeFormatter = "YYYY-MM-DD".equals(granularity) ?
DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.of("UTC")) : null; DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.of("UTC")) : null;
try (MarcJsonWriter writer = new MarcJsonWriter("build/bk-bulk%d.jsonl", 1000, try (MarcJsonWriter writer = new MarcJsonWriter("build/bk-bulk%d.jsonl", 1000, 8192, false)
EnumSet.of(MarcJsonWriter.Style.ELASTICSEARCH_BULK), 8192, false) .setStyle(EnumSet.of(MarcJsonWriter.Style.ELASTICSEARCH_BULK))
.setIndex("bk", "type")) { .setIndex("bk", "type")) {
writer.startDocument(); writer.startDocument();
writer.beginCollection(); writer.beginCollection();

View file

@ -1,21 +1,13 @@
package org.xbib.oai.client; package org.xbib.oai.client;
import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.oai.client.identify.IdentifyResponse;
import org.xbib.oai.xml.SimpleMetadataHandler;
import java.time.Instant; import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.Logger;
@Disabled("port is locked")
class DNBClientTest { class DNBClientTest {
private static final Logger logger = Logger.getLogger(DNBClientTest.class.getName());
@Test @Test
void testBibdatFileDump() throws Exception { void testBibdatFileDump() throws Exception {
OAIClient oaiClient = new OAIClient("http://services.dnb.de/oai/repository"); OAIClient oaiClient = new OAIClient("http://services.dnb.de/oai/repository");
@ -35,39 +27,12 @@ class DNBClientTest {
oaiClient.setUserAgent("Hochschulbibliothekszentrum Nordrhein-Westfalen (prante@hbz-nrw.de)"); oaiClient.setUserAgent("Hochschulbibliothekszentrum Nordrhein-Westfalen (prante@hbz-nrw.de)");
Instant base = Instant.parse("2010-01-01T00:00:00Z"); Instant base = Instant.parse("2010-01-01T00:00:00Z");
//IdentifyResponse identifyResponse = oaiClient.identify();
//String granularity = identifyResponse.getGranularity();
//logger.log(Level.INFO, "granularity = " + granularity);
//DateTimeFormatter dateTimeFormatter = "YYYY-MM-DD".equals(granularity) ?
// DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.of("UTC")) : null;
SplitWriter splitWriter = new SplitWriter("build/bibdat-test-%d.xml", -1, 8192, false); SplitWriter splitWriter = new SplitWriter("build/bibdat-test-%d.xml", -1, 8192, false);
oaiClient.setSplitWriter(splitWriter); oaiClient.setSplitWriter(splitWriter);
// Handler handler = new Handler();
oaiClient.listRecords("PicaPlus-xml", "bib", null, oaiClient.listRecords("PicaPlus-xml", "bib", null,
Instant.parse("2016-01-01T00:00:00Z"), Instant.parse("2016-01-01T00:00:00Z"),
Instant.parse("2016-02-01T00:00:00Z"), Instant.parse("2016-02-01T00:00:00Z"),
base, null, null); base, null, null);
//logger.log(Level.INFO, "count=" + handler.count());
//assertTrue(handler.count() > 0);
} }
static class Handler extends SimpleMetadataHandler {
final AtomicLong count = new AtomicLong(0L);
@Override
public void startDocument() {
logger.log(Level.INFO, "start doc");
}
@Override
public void endDocument() {
logger.log(Level.INFO, "end doc");
count.incrementAndGet();
}
long count() {
return count.get();
}
}
} }

View file

@ -1,9 +1,9 @@
dependencyResolutionManagement { dependencyResolutionManagement {
versionCatalogs { versionCatalogs {
libs { libs {
version('gradle', '7.5.1') version('gradle', '8.1.1')
version('junit', '5.9.1') version('junit', '5.9.3')
version('content', '5.0.1') version('content', '5.0.3')
library('junit-jupiter-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit') 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-params', 'org.junit.jupiter', 'junit-jupiter-params').versionRef('junit')
library('junit-jupiter-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit') library('junit-jupiter-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit')
@ -12,8 +12,8 @@ dependencyResolutionManagement {
library('content-rdf', 'org.xbib', 'content-rdf').versionRef('content') library('content-rdf', 'org.xbib', 'content-rdf').versionRef('content')
library('content-resource', 'org.xbib', 'content-resource').versionRef('content') library('content-resource', 'org.xbib', 'content-resource').versionRef('content')
library('content-xml', 'org.xbib', 'content-xml').versionRef('content') library('content-xml', 'org.xbib', 'content-xml').versionRef('content')
library('marc', 'org.xbib', 'marc').version('2.7.1') library('marc', 'org.xbib', 'marc').version('2.11.0')
library('charactersets', 'org.xbib', 'bibliographic-character-sets').version('2.0.0') library('charactersets', 'org.xbib', 'bibliographic-character-sets').version('3.0.0')
} }
} }
} }