diff --git a/build.gradle b/build.gradle index fbd45cb..9bacf0f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,33 +1,10 @@ plugins { + id "com.github.spotbugs" version "2.0.0" id "org.sonarqube" version '2.6.1' id "io.codearte.nexus-staging" version "0.11.0" id "org.xbib.gradle.plugin.asciidoctor" version "1.5.6.0.1" } -printf "Host: %s\nOS: %s %s %s\nJVM: %s %s %s %s\nGradle: %s Groovy: %s Java: %s\n" + - "Build: group: ${project.group} name: ${project.name} version: ${project.version}\n", - InetAddress.getLocalHost(), - System.getProperty("os.name"), - System.getProperty("os.arch"), - System.getProperty("os.version"), - System.getProperty("java.version"), - System.getProperty("java.vm.version"), - System.getProperty("java.vm.vendor"), - System.getProperty("java.vm.name"), - gradle.gradleVersion, - GroovySystem.getVersion(), - JavaVersion.current() - -apply plugin: 'java' -apply plugin: 'org.xbib.gradle.plugin.asciidoctor' - -configurations { - asciidoclet -} - -dependencies { - asciidoclet "org.asciidoctor:asciidoclet:${project.property('asciidoclet.version')}" -} asciidoctor { backends 'html5' @@ -40,7 +17,7 @@ asciidoctor { stylesheet: "${projectDir}/src/docs/asciidoc/css/foundation.css" } -javadoc { +/*javadoc { options.docletpath = configurations.asciidoclet.files.asType(List) options.doclet = 'org.asciidoctor.Asciidoclet' options.overview = "${rootProject.projectDir}/src/docs/asciidoclet/overview.adoc" @@ -51,42 +28,54 @@ javadoc { configure(options) { noTimestamp = true } -} +}*/ subprojects { apply plugin: 'java' apply plugin: 'maven' - apply plugin: 'signing' - apply plugin: 'findbugs' apply plugin: 'pmd' apply plugin: 'checkstyle' - apply plugin: 'jacoco' - - repositories { - mavenCentral() - } - - configurations { - wagon - } + apply plugin: "com.github.spotbugs" dependencies { - testCompile "junit:junit:${project.property('junit.version')}" - wagon "org.apache.maven.wagon:wagon-ssh:${project.property('wagon.version')}" + testImplementation "org.junit.jupiter:junit-jupiter-api:${project.property('junit.version')}" + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${project.property('junit.version')}" + testImplementation "org.xbib:bibliographic-character-sets:${project.property('xbib-bibliographic-character-sets.version')}" } - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + compileJava { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + compileTestJava { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } - [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' tasks.withType(JavaCompile) { - options.compilerArgs << "-Xlint:all,-fallthrough" << "-profile" << "compact1" + options.compilerArgs << "-Xlint:all,-fallthrough" + } + + clean { + delete 'out' } test { + useJUnitPlatform() + systemProperty 'java.util.logging.config.file', project.file('src/test/resources/logging.properties') + failFast = false testLogging { - showStandardStreams = false - exceptionFormat = 'full' + events 'STARTED', 'PASSED', 'FAILED', 'SKIPPED' + } + afterSuite { desc, result -> + if (!desc.parent) { + println "\nTest result: ${result.resultType}" + println "Test summary: ${result.testCount} tests, " + + "${result.successfulTestCount} succeeded, " + + "${result.failedTestCount} failed, " + + "${result.skippedTestCount} skipped" + } } } @@ -103,13 +92,124 @@ subprojects { archives sourcesJar, javadocJar } - if (project.hasProperty('signing.keyId')) { - signing { - sign configurations.archives + ext { + user = 'xbib' + projectName = 'cql' + projectDescription = 'Contextual Query Language compiler for Java' + scmUrl = 'https://github.com/xbib/cql' + scmConnection = 'scm:git:git://github.com/xbib/cql.git' + scmDeveloperConnection = 'scm:git:git://github.com/xbib/cql.git' + } + + spotbugs { + toolVersion = '3.1.12' + sourceSets = [sourceSets.main] + ignoreFailures = true + effort = "max" + reportLevel = "high" + } + + spotbugsMain.reports { + xml.enabled = false + html.enabled = true + } + + spotbugsTest.reports { + xml.enabled = false + html.enabled = true + } + + tasks.withType(Pmd) { + ignoreFailures = true + reports { + xml.enabled = true + html.enabled = true } } - apply from: "${rootProject.projectDir}/gradle/ext.gradle" - apply from: "${rootProject.projectDir}/gradle/publish.gradle" - apply from: "${rootProject.projectDir}/gradle/sonarqube.gradle" + tasks.withType(Checkstyle) { + ignoreFailures = true + reports { + xml.enabled = true + html.enabled = true + } + } + + pmd { + toolVersion = '6.11.0' + ruleSets = ['category/java/bestpractices.xml'] + } + + checkstyle { + configFile = rootProject.file('config/checkstyle/checkstyle.xml') + ignoreFailures = true + showViolations = true + } + + 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/" + } + } + + task sonatypeUpload(type: Upload, dependsOn: build) { + group = 'publish' + configuration = configurations.archives + uploadDescriptor = true + repositories { + if (project.hasProperty('ossrhUsername')) { + mavenDeployer { + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + repository(url: uri(ossrhReleaseUrl)) { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + snapshotRepository(url: uri(ossrhSnapshotUrl)) { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + pom.project { + groupId project.group + artifactId project.name + version project.version + name project.name + description projectDescription + packaging 'jar' + inceptionYear '2016' + url scmUrl + organization { + name 'xbib' + url 'http://xbib.org' + } + developers { + developer { + id user + name 'Jörg Prante' + email 'joergprante@gmail.com' + url 'https://github.com/jprante' + } + } + scm { + url scmUrl + connection scmConnection + developerConnection scmDeveloperConnection + } + licenses { + license { + name 'The Apache License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + } + } + } + } + } + + nexusStaging { + packageGroup = "org.xbib" + } + } diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 42d1e17..20fd3f0 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -10,7 +10,7 @@ page at http://checkstyle.sourceforge.net/config.html --> - + diff --git a/cql-common/src/main/java/org/xbib/cql/util/QueryStringDecoder.java b/cql-common/src/main/java/org/xbib/cql/util/QueryStringDecoder.java index be264a6..fb8dac1 100644 --- a/cql-common/src/main/java/org/xbib/cql/util/QueryStringDecoder.java +++ b/cql-common/src/main/java/org/xbib/cql/util/QueryStringDecoder.java @@ -21,7 +21,7 @@ import java.util.Map; * assert decoder.getParameters().get("y").get(0).equals("2"); * * This decoder can also decode the content of an HTTP POST request whose - * content type is application/x-www-form-urlencoded: + * content type is {@code application/x-www-form-urlencoded}: *
  * {@link QueryStringDecoder} decoder = new {@link QueryStringDecoder}("recipient=world&x=1;y=2", false);
  * 
diff --git a/cql-common/src/test/java/org/xbib/cql/QueryTest.java b/cql-common/src/test/java/org/xbib/cql/QueryTest.java index db580ff..93ed067 100644 --- a/cql-common/src/test/java/org/xbib/cql/QueryTest.java +++ b/cql-common/src/test/java/org/xbib/cql/QueryTest.java @@ -1,20 +1,21 @@ package org.xbib.cql; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.io.InputStreamReader; import java.io.LineNumberReader; import java.nio.charset.StandardCharsets; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * */ -public class QueryTest extends Assert { +class QueryTest { @Test - public void testValidQueries() throws IOException { + void testValidQueries() throws IOException { test("queries.txt"); } diff --git a/cql-common/src/test/java/org/xbib/cql/util/QuotedStringTokenizerTest.java b/cql-common/src/test/java/org/xbib/cql/util/QuotedStringTokenizerTest.java index 940bcfa..6992532 100644 --- a/cql-common/src/test/java/org/xbib/cql/util/QuotedStringTokenizerTest.java +++ b/cql-common/src/test/java/org/xbib/cql/util/QuotedStringTokenizerTest.java @@ -1,16 +1,16 @@ package org.xbib.cql.util; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * */ -public class QuotedStringTokenizerTest { +class QuotedStringTokenizerTest { @Test - public void testTokenizer() throws Exception { + void testTokenizer() throws Exception { String s = "Linux is \"pinguin's best friend\", not Windows"; QuotedStringTokenizer tokenizer = new QuotedStringTokenizer(s); assertEquals("Linux", tokenizer.nextToken()); diff --git a/cql-elasticsearch/src/test/java/org/xbib/cql/elasticsearch/ElasticsearchQueryTest.java b/cql-elasticsearch/src/test/java/org/xbib/cql/elasticsearch/ElasticsearchQueryTest.java index bb5eed0..7f04101 100644 --- a/cql-elasticsearch/src/test/java/org/xbib/cql/elasticsearch/ElasticsearchQueryTest.java +++ b/cql-elasticsearch/src/test/java/org/xbib/cql/elasticsearch/ElasticsearchQueryTest.java @@ -1,7 +1,6 @@ package org.xbib.cql.elasticsearch; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.xbib.cql.CQLParser; import java.io.IOException; @@ -9,18 +8,20 @@ import java.io.InputStreamReader; import java.io.LineNumberReader; import java.nio.charset.StandardCharsets; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * */ -public class ElasticsearchQueryTest extends Assert { +class ElasticsearchQueryTest { @Test - public void testValidQueries() throws IOException { + void testValidQueries() throws IOException { test("queries.txt"); } @Test - public void testSimpleTermFilter() throws Exception { + void testSimpleTermFilter() throws Exception { String cql = "Jörg"; CQLParser parser = new CQLParser(cql); parser.parse(); @@ -31,7 +32,7 @@ public class ElasticsearchQueryTest extends Assert { } @Test - public void testFieldTermFilter() throws Exception { + void testFieldTermFilter() throws Exception { String cql = "dc.type = electronic"; CQLParser parser = new CQLParser(cql); parser.parse(); @@ -42,7 +43,7 @@ public class ElasticsearchQueryTest extends Assert { } @Test - public void testDoubleFieldTermFilter() throws Exception { + void testDoubleFieldTermFilter() throws Exception { String cql = "dc.type = electronic and dc.date = 2013"; CQLParser parser = new CQLParser(cql); parser.parse(); @@ -56,7 +57,7 @@ public class ElasticsearchQueryTest extends Assert { } @Test - public void testTripleFieldTermFilter() throws Exception { + void testTripleFieldTermFilter() throws Exception { String cql = "dc.format = online and dc.type = electronic and dc.date = 2013"; CQLParser parser = new CQLParser(cql); parser.parse(); @@ -70,7 +71,7 @@ public class ElasticsearchQueryTest extends Assert { } @Test - public void testBoost() throws Exception { + void testBoost() throws Exception { String cql = "Jörg"; CQLParser parser = new CQLParser(cql); parser.parse(); @@ -87,7 +88,7 @@ public class ElasticsearchQueryTest extends Assert { } @Test - public void testWildcardTerm() throws Exception { + void testWildcardTerm() throws Exception { String cql = "dc.format = book*"; CQLParser parser = new CQLParser(cql); parser.parse(); diff --git a/gradle.properties b/gradle.properties index 47aedc0..97acf7a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ group = org.xbib name = cql -version = 1.2.0 +version = 2.0.0 -xbib-content.version = 1.3.0 -junit.version = 4.12 -wagon.version = 3.0.0 -asciidoclet.version = 1.5.4 +xbib-content.version = 2.0.0 +xbib-bibliographic-character-sets.version = 1.0.0 + +junit.version = 5.5.1 diff --git a/gradle/ext.gradle b/gradle/ext.gradle deleted file mode 100644 index 9b3403e..0000000 --- a/gradle/ext.gradle +++ /dev/null @@ -1,8 +0,0 @@ -ext { - user = 'xbib' - projectName = 'cql' - projectDescription = 'Contextual Query Language compiler for Java' - scmUrl = 'https://github.com/xbib/cql' - scmConnection = 'scm:git:git://github.com/xbib/cql.git' - scmDeveloperConnection = 'scm:git:git://github.com/xbib/cql.git' -} diff --git a/gradle/publish.gradle b/gradle/publish.gradle deleted file mode 100644 index b6678b6..0000000 --- a/gradle/publish.gradle +++ /dev/null @@ -1,104 +0,0 @@ - -task xbibUpload(type: Upload, dependsOn: build) { - group = 'publish' - configuration = configurations.archives - uploadDescriptor = true - repositories { - if (project.hasProperty('xbibUsername')) { - mavenDeployer { - configuration = configurations.wagon - repository(url: uri('sftp://xbib.org/repository')) { - authentication(userName: xbibUsername, privateKey: xbibPrivateKey) - } - pom.project { - groupId project.group - artifactId project.name - version project.version - name project.name - description projectDescription - packaging 'jar' - inceptionYear '2016' - url scmUrl - organization { - name 'xbib' - url 'http://xbib.org' - } - developers { - developer { - id user - name 'Jörg Prante' - email 'joergprante@gmail.com' - url 'https://github.com/jprante' - } - } - scm { - url scmUrl - connection scmConnection - developerConnection scmDeveloperConnection - } - licenses { - license { - name 'The Apache License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - } } - } - } -} - -task sonatypeUpload(type: Upload, dependsOn: build) { - group = 'publish' - configuration = configurations.archives - uploadDescriptor = true - repositories { - if (project.hasProperty('ossrhUsername')) { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - repository(url: uri(ossrhReleaseUrl)) { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - snapshotRepository(url: uri(ossrhSnapshotUrl)) { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - pom.project { - groupId project.group - artifactId project.name - version project.version - name project.name - description projectDescription - packaging 'jar' - inceptionYear '2016' - url scmUrl - organization { - name 'xbib' - url 'http://xbib.org' - } - developers { - developer { - id user - name 'Jörg Prante' - email 'joergprante@gmail.com' - url 'https://github.com/jprante' - } - } - scm { - url scmUrl - connection scmConnection - developerConnection scmDeveloperConnection - } - licenses { - license { - name 'The Apache License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - } - } - } - } -} - -nexusStaging { - packageGroup = "org.xbib" -} diff --git a/gradle/sonarqube.gradle b/gradle/sonarqube.gradle deleted file mode 100644 index a5e21a3..0000000 --- a/gradle/sonarqube.gradle +++ /dev/null @@ -1,40 +0,0 @@ - -tasks.withType(FindBugs) { - ignoreFailures = true - reports { - xml.enabled = false - html.enabled = true - } -} -tasks.withType(Pmd) { - ignoreFailures = true - reports { - xml.enabled = true - html.enabled = true - } -} -tasks.withType(Checkstyle) { - ignoreFailures = true - reports { - xml.enabled = true - html.enabled = true - } -} - -jacocoTestReport { - reports { - xml.enabled = true - csv.enabled = false - } -} - -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.java.coveragePlugin", "jacoco" - property "sonar.junit.reportsPath", "build/test-results/test/" - } -} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c44b679..5c2d1cf 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 20572e7..9a71a62 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Feb 08 11:11:10 CET 2018 +#Mon Aug 12 10:55:55 CEST 2019 +distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-all.zip +zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index cccdd3d..b0d6d0a 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" diff --git a/gradlew.bat b/gradlew.bat index e95643d..15e1ee3 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem http://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome