From dd635c54b245e8f71862ff7edadbca79b9f9ffc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Thu, 4 Jun 2020 23:41:01 +0200 Subject: [PATCH] Jackson 2.11, update named modules, add pmd/checkstyle/spotbugs --- build.gradle | 6 + config/checkstyle/checkstyle.xml | 34 +- content-core/src/main/java/module-info.java | 2 +- .../org/xbib/content/json/JsonXContent.java | 4 +- content-json/build.gradle | 3 - content-json/src/main/java/module-info.java | 3 +- .../json/jackson/JsonNodeReaderTest.java | 25 +- .../json/jackson/JsonNumEqualsTest.java | 7 +- .../json/pointer/JsonNodeResolverTest.java | 20 +- .../content/json/pointer/JsonPointerTest.java | 17 +- .../json/pointer/ReferenceTokenTest.java | 56 ++- .../content/json/pointer/TreePointerTest.java | 33 +- content-rdf/src/main/java/module-info.java | 7 +- .../config/checkstyle/checkstyle.xml | 323 ------------------ content-smile/src/main/java/module-info.java | 4 +- content-xml/src/main/java/module-info.java | 9 +- .../org/xbib/content/xml/XmlXContent.java | 2 +- content-yaml/build.gradle | 1 + content-yaml/src/main/java/module-info.java | 4 +- gradle.properties | 10 +- gradle/compile/java.gradle | 8 + gradle/quality/checkstyle.gradle | 27 ++ gradle/quality/pmd.gradle | 9 + gradle/quality/spotbugs.gradle | 18 + 24 files changed, 169 insertions(+), 463 deletions(-) delete mode 100644 content-smile/config/checkstyle/checkstyle.xml create mode 100644 gradle/quality/checkstyle.gradle create mode 100644 gradle/quality/pmd.gradle create mode 100644 gradle/quality/spotbugs.gradle diff --git a/build.gradle b/build.gradle index 9d3b235..0702dd2 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,9 @@ 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 "1.5.6.0.1" + id "com.github.spotbugs" version "4.2.4" + id "pmd" + id "checkstyle" } wrapper { @@ -29,6 +32,9 @@ subprojects { apply from: rootProject.file('gradle/ide/idea.gradle') apply from: rootProject.file('gradle/compile/java.gradle') apply from: rootProject.file('gradle/test/junit5.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/publishing/publication.gradle') } apply from: rootProject.file('gradle/publishing/sonatype.gradle') diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 773fc1a..2321bcb 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -38,6 +38,22 @@ page at http://checkstyle.sourceforge.net/config.html --> Only allows a package-info.java, not package.html. --> + + + + + + + + + + @@ -75,9 +91,6 @@ page at http://checkstyle.sourceforge.net/config.html --> - - - @@ -183,21 +196,6 @@ page at http://checkstyle.sourceforge.net/config.html --> --> - - - - - - - - - diff --git a/content-core/src/main/java/module-info.java b/content-core/src/main/java/module-info.java index c29c994..9a040d4 100644 --- a/content-core/src/main/java/module-info.java +++ b/content-core/src/main/java/module-info.java @@ -5,7 +5,7 @@ module org.xbib.content.core { exports org.xbib.content.settings; exports org.xbib.content.util.geo; exports org.xbib.content.util.unit; - requires com.fasterxml.jackson.core; + requires transitive com.fasterxml.jackson.core; provides org.xbib.content.XContent with org.xbib.content.json.JsonXContent; provides org.xbib.content.settings.SettingsLoader with diff --git a/content-core/src/main/java/org/xbib/content/json/JsonXContent.java b/content-core/src/main/java/org/xbib/content/json/JsonXContent.java index 34c5478..7a0d5e9 100644 --- a/content-core/src/main/java/org/xbib/content/json/JsonXContent.java +++ b/content-core/src/main/java/org/xbib/content/json/JsonXContent.java @@ -2,7 +2,6 @@ package org.xbib.content.json; import com.fasterxml.jackson.core.JsonEncoding; import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import org.xbib.content.XContent; import org.xbib.content.XContentBuilder; @@ -29,7 +28,6 @@ public class JsonXContent implements XContent { static { jsonFactory = new JsonFactory(); jsonFactory.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); - jsonFactory.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true); jsonXContent = new JsonXContent(); } @@ -97,7 +95,7 @@ public class JsonXContent implements XContent { @Override public boolean isXContent(BytesReference bytes) { - int length = bytes.length() < 20 ? bytes.length() : 20; + int length = Math.min(bytes.length(), 20); if (length == 0) { return false; } diff --git a/content-json/build.gradle b/content-json/build.gradle index 0b1fcf4..2708c43 100644 --- a/content-json/build.gradle +++ b/content-json/build.gradle @@ -1,8 +1,5 @@ dependencies { api "com.fasterxml.jackson.core:jackson-databind:${project.property('jackson.version')}" - testImplementation("junit:junit:${project.property('junit4.version')}") { - exclude group: 'org.hamcrest' - } testImplementation("org.mockito:mockito-core:${project.property('mockito.version')}") { exclude group: 'org.hamcrest' } diff --git a/content-json/src/main/java/module-info.java b/content-json/src/main/java/module-info.java index 0611013..0452788 100644 --- a/content-json/src/main/java/module-info.java +++ b/content-json/src/main/java/module-info.java @@ -4,5 +4,6 @@ module org.xbib.content.json { exports org.xbib.content.json.mergepatch; exports org.xbib.content.json.patch; exports org.xbib.content.json.pointer; - requires com.fasterxml.jackson.databind; + requires transitive com.fasterxml.jackson.core; + requires transitive com.fasterxml.jackson.databind; } diff --git a/content-json/src/test/java/org/xbib/content/json/jackson/JsonNodeReaderTest.java b/content-json/src/test/java/org/xbib/content/json/jackson/JsonNodeReaderTest.java index dbdd531..6a0a4c7 100644 --- a/content-json/src/test/java/org/xbib/content/json/jackson/JsonNodeReaderTest.java +++ b/content-json/src/test/java/org/xbib/content/json/jackson/JsonNodeReaderTest.java @@ -1,29 +1,29 @@ package org.xbib.content.json.jackson; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; - import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Test; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.io.StringReader; +import java.nio.charset.StandardCharsets; /** * */ -public final class JsonNodeReaderTest extends Assert { +public final class JsonNodeReaderTest { @Test public void streamIsClosedOnRead() throws IOException { - final InputStream in = spy(new ByteArrayInputStream("[]".getBytes("UTF-8"))); + final InputStream in = spy(new ByteArrayInputStream("[]".getBytes(StandardCharsets.UTF_8))); final JsonNode node = new JsonNodeReader().fromInputStream(in); verify(in).close(); assertEquals(node, new ObjectMapper().readTree(new ByteArrayInputStream("[]".getBytes("UTF-8")))); @@ -39,21 +39,14 @@ public final class JsonNodeReaderTest extends Assert { } @Test - public void malformedDataThrowsExpectedException() - throws IOException { - + public void malformedDataThrowsExpectedException() { String[] inputs = new String[]{ "", "[]{}", "[]]" }; final JsonNodeReader reader = new JsonNodeReader(); for (String input : inputs) { - try { - reader.fromInputStream(new ByteArrayInputStream(input.getBytes())); - fail("No exception thrown!!"); - } catch (JsonParseException e) { - // - } + Assertions.assertThrows(JsonParseException.class, () -> + reader.fromInputStream(new ByteArrayInputStream(input.getBytes()))); } } - } diff --git a/content-json/src/test/java/org/xbib/content/json/jackson/JsonNumEqualsTest.java b/content-json/src/test/java/org/xbib/content/json/jackson/JsonNumEqualsTest.java index 57217fe..bd25316 100644 --- a/content-json/src/test/java/org/xbib/content/json/jackson/JsonNumEqualsTest.java +++ b/content-json/src/test/java/org/xbib/content/json/jackson/JsonNumEqualsTest.java @@ -1,12 +1,11 @@ package org.xbib.content.json.jackson; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.Assert; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; @@ -15,7 +14,7 @@ import java.util.List; /** * */ -public final class JsonNumEqualsTest extends Assert { +public final class JsonNumEqualsTest { private static final JsonNodeFactory FACTORY = JsonNodeFactory.instance; diff --git a/content-json/src/test/java/org/xbib/content/json/pointer/JsonNodeResolverTest.java b/content-json/src/test/java/org/xbib/content/json/pointer/JsonNodeResolverTest.java index 557ac77..9a35772 100644 --- a/content-json/src/test/java/org/xbib/content/json/pointer/JsonNodeResolverTest.java +++ b/content-json/src/test/java/org/xbib/content/json/pointer/JsonNodeResolverTest.java @@ -1,29 +1,29 @@ package org.xbib.content.json.pointer; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.xbib.content.json.jackson.JacksonUtils; import org.xbib.content.json.jackson.NodeType; import org.xbib.content.json.jackson.SampleNodeProvider; - import java.util.ArrayList; import java.util.List; /** * */ -public final class JsonNodeResolverTest extends Assert { +public final class JsonNodeResolverTest { + private static final JsonNodeFactory FACTORY = JacksonUtils.nodeFactory(); @Test public void resolvingNullReturnsNull() { final JsonNodeResolver resolver = new JsonNodeResolver(ReferenceToken.fromRaw("whatever")); - assertNull(resolver.get(null)); } @@ -33,7 +33,6 @@ public final class JsonNodeResolverTest extends Assert { NodeType.OBJECT).next()[0]; final JsonNodeResolver resolver = new JsonNodeResolver(ReferenceToken.fromRaw("whatever")); - assertNull(resolver.get(node)); } @@ -42,18 +41,13 @@ public final class JsonNodeResolverTest extends Assert { final JsonNodeResolver resolver = new JsonNodeResolver(ReferenceToken.fromRaw("a")); final JsonNode target = FACTORY.textNode("b"); - ObjectNode node; - node = FACTORY.objectNode(); node.set("a", target); - final JsonNode resolved = resolver.get(node); assertEquals(resolved, target); - node = FACTORY.objectNode(); node.set("b", target); - assertNull(resolver.get(node)); } @@ -61,13 +55,10 @@ public final class JsonNodeResolverTest extends Assert { public void resolvingArrayIndicesWorks() { final JsonNodeResolver resolver = new JsonNodeResolver(ReferenceToken.fromInt(1)); - final JsonNode target = FACTORY.textNode("b"); final ArrayNode node = FACTORY.arrayNode(); - node.add(target); assertNull(resolver.get(node)); - node.add(target); assertEquals(target, resolver.get(node)); } @@ -77,7 +68,6 @@ public final class JsonNodeResolverTest extends Assert { final JsonNode target = FACTORY.textNode("b"); final ArrayNode node = FACTORY.arrayNode(); node.add(target); - List list = new ArrayList<>(); list.add(new Object[]{"-1"}); list.add(new Object[]{"232398087298731987987232"}); diff --git a/content-json/src/test/java/org/xbib/content/json/pointer/JsonPointerTest.java b/content-json/src/test/java/org/xbib/content/json/pointer/JsonPointerTest.java index 42090f5..e910b8b 100644 --- a/content-json/src/test/java/org/xbib/content/json/pointer/JsonPointerTest.java +++ b/content-json/src/test/java/org/xbib/content/json/pointer/JsonPointerTest.java @@ -1,13 +1,13 @@ package org.xbib.content.json.pointer; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.fasterxml.jackson.databind.JsonNode; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.xbib.content.json.jackson.JacksonUtils; import org.xbib.content.json.jackson.JsonLoader; import org.xbib.content.json.jackson.NodeType; import org.xbib.content.json.jackson.SampleNodeProvider; - import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -20,7 +20,7 @@ import java.util.Map; /** * */ -public final class JsonPointerTest extends Assert { +public final class JsonPointerTest { private static final String PACKAGE = JsonPointerTest.class.getPackage().getName().replace('.', '/'); private final JsonNode testData; @@ -33,11 +33,12 @@ public final class JsonPointerTest extends Assert { document = testData.get("document"); } - @Test(expected = NullPointerException.class) + @Test public void cannotAppendNullPointer() { - final JsonPointer foo = null; - JsonPointer.empty().append(foo); - fail("No exception thrown!!"); + Assertions.assertThrows(NullPointerException.class, () -> { + final JsonPointer foo = null; + JsonPointer.empty().append(foo); + }); } @Test diff --git a/content-json/src/test/java/org/xbib/content/json/pointer/ReferenceTokenTest.java b/content-json/src/test/java/org/xbib/content/json/pointer/ReferenceTokenTest.java index 68fe27d..3214b2a 100644 --- a/content-json/src/test/java/org/xbib/content/json/pointer/ReferenceTokenTest.java +++ b/content-json/src/test/java/org/xbib/content/json/pointer/ReferenceTokenTest.java @@ -1,55 +1,39 @@ package org.xbib.content.json.pointer; -import org.junit.Assert; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; /** * */ -public final class ReferenceTokenTest extends Assert { +public final class ReferenceTokenTest { @Test - public void nullCookedRaisesError() - throws JsonPointerException { - try { - ReferenceToken.fromCooked(null); - fail("No exception thrown!!"); - } catch (NullPointerException e) { - //assertEquals(e.getMessage(), BUNDLE.getMessage("nullInput")); - } + public void nullCookedRaisesError() { + Assertions.assertThrows(NullPointerException.class, () -> + ReferenceToken.fromCooked(null)); } @Test public void nullRawRaisesError() { - try { - ReferenceToken.fromRaw(null); - fail("No exception thrown!!"); - } catch (NullPointerException e) { - //assertEquals(e.getMessage(), BUNDLE.getMessage("nullInput")); - } + Assertions.assertThrows(NullPointerException.class, () -> + ReferenceToken.fromRaw(null)); } @Test public void emptyEscapeRaisesTheAppropriateException() { - try { - ReferenceToken.fromCooked("whatever~"); - fail("No exception thrown!!"); - } catch (JsonPointerException e) { - //assertEquals(e.getMessage(), BUNDLE.getMessage("emptyEscape")); - } + Assertions.assertThrows(JsonPointerException.class, () -> + ReferenceToken.fromCooked("whatever~")); } @Test public void illegalEscapeRaisesTheAppropriateException() { - try { - ReferenceToken.fromCooked("~a"); - fail("No exception thrown!!"); - } catch (JsonPointerException e) { - //assertEquals(e.getMessage(), BUNDLE.getMessage("illegalEscape")); - } + Assertions.assertThrows(JsonPointerException.class, () -> + ReferenceToken.fromCooked("~a")); } @Test @@ -68,8 +52,7 @@ public final class ReferenceTokenTest extends Assert { String raw = (String) o[1]; final ReferenceToken token1 = ReferenceToken.fromCooked(cooked); final ReferenceToken token2 = ReferenceToken.fromRaw(raw); - - assertTrue(token1.equals(token2)); + assertEquals(token1, token2); assertEquals(token2.toString(), cooked); } } @@ -88,9 +71,9 @@ public final class ReferenceTokenTest extends Assert { final ReferenceToken fromInt = ReferenceToken.fromInt(index); final ReferenceToken cooked = ReferenceToken.fromCooked(asString); final ReferenceToken raw = ReferenceToken.fromRaw(asString); - assertTrue(fromInt.equals(cooked)); - assertTrue(cooked.equals(raw)); - assertTrue(raw.equals(fromInt)); + assertEquals(fromInt, cooked); + assertEquals(cooked, raw); + assertEquals(raw, fromInt); assertEquals(fromInt.toString(), asString); } } @@ -100,7 +83,6 @@ public final class ReferenceTokenTest extends Assert { throws JsonPointerException { final ReferenceToken zero = ReferenceToken.fromCooked("0"); final ReferenceToken zerozero = ReferenceToken.fromCooked("00"); - - assertFalse(zero.equals(zerozero)); + assertNotEquals(zero, zerozero); } } diff --git a/content-json/src/test/java/org/xbib/content/json/pointer/TreePointerTest.java b/content-json/src/test/java/org/xbib/content/json/pointer/TreePointerTest.java index 482547f..50886a0 100644 --- a/content-json/src/test/java/org/xbib/content/json/pointer/TreePointerTest.java +++ b/content-json/src/test/java/org/xbib/content/json/pointer/TreePointerTest.java @@ -1,16 +1,19 @@ package org.xbib.content.json.pointer; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.only; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; - import com.fasterxml.jackson.core.TreeNode; -import org.junit.Assert; -import org.junit.Test; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -19,24 +22,24 @@ import java.util.List; /** * */ -public final class TreePointerTest extends Assert { - @Test(expected = NullPointerException.class) - public void attemptToBuildTokensFromNullRaisesAnError() throws JsonPointerException { - TreePointer.tokensFromInput(null); - fail("No exception thrown!!"); +public final class TreePointerTest { + + @Test + public void attemptToBuildTokensFromNullRaisesAnError() { + Assertions.assertThrows(NullPointerException.class, () -> + TreePointer.tokensFromInput(null)); } - @Test(expected = JsonPointerException.class) - public void buildingTokenListYellsIfIllegalPointer() throws JsonPointerException { - TreePointer.tokensFromInput("a/b"); - fail("No exception thrown!!"); + @Test + public void buildingTokenListYellsIfIllegalPointer() { + Assertions.assertThrows(JsonPointerException.class, () -> + TreePointer.tokensFromInput("a/b")); } @Test public void buildingTokenListIsUnfazedByAnEmptyInput() throws JsonPointerException { - assertEquals(TreePointer.tokensFromInput(""), - new ArrayList<>()); + assertEquals(TreePointer.tokensFromInput(""), new ArrayList<>()); } @Test diff --git a/content-rdf/src/main/java/module-info.java b/content-rdf/src/main/java/module-info.java index 73edb1b..ab7e01d 100644 --- a/content-rdf/src/main/java/module-info.java +++ b/content-rdf/src/main/java/module-info.java @@ -10,8 +10,7 @@ module org.xbib.content.rdf { exports org.xbib.content.rdf.io.turtle; exports org.xbib.content.rdf.io.xml; exports org.xbib.content.rdf.util; - requires org.xbib.content.core; - requires org.xbib.content.resource; - requires org.xbib.content.xml; - requires java.xml; + requires transitive org.xbib.content.core; + requires transitive org.xbib.content.resource; + requires transitive org.xbib.content.xml; } diff --git a/content-smile/config/checkstyle/checkstyle.xml b/content-smile/config/checkstyle/checkstyle.xml deleted file mode 100644 index 52fe33c..0000000 --- a/content-smile/config/checkstyle/checkstyle.xml +++ /dev/null @@ -1,323 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/content-smile/src/main/java/module-info.java b/content-smile/src/main/java/module-info.java index 953910f..f1d27bf 100644 --- a/content-smile/src/main/java/module-info.java +++ b/content-smile/src/main/java/module-info.java @@ -1,7 +1,7 @@ module org.xbib.content.smile { exports org.xbib.content.smile; - requires org.xbib.content.core; - requires com.fasterxml.jackson.dataformat.smile; + requires transitive org.xbib.content.core; + requires transitive com.fasterxml.jackson.dataformat.smile; provides org.xbib.content.XContent with org.xbib.content.smile.SmileXContent; } diff --git a/content-xml/src/main/java/module-info.java b/content-xml/src/main/java/module-info.java index fae3918..2ec0337 100644 --- a/content-xml/src/main/java/module-info.java +++ b/content-xml/src/main/java/module-info.java @@ -5,11 +5,10 @@ module org.xbib.content.xml { exports org.xbib.content.xml.stream; exports org.xbib.content.xml.transform; exports org.xbib.content.xml.util; - requires java.xml; - requires org.xbib.content.core; - requires org.xbib.content.resource; - requires com.fasterxml.jackson.core; - requires com.fasterxml.jackson.dataformat.xml; + requires transitive java.xml; + requires transitive org.xbib.content.core; + requires transitive org.xbib.content.resource; + requires transitive com.fasterxml.jackson.dataformat.xml; provides org.xbib.content.XContent with org.xbib.content.xml.XmlXContent; } diff --git a/content-xml/src/main/java/org/xbib/content/xml/XmlXContent.java b/content-xml/src/main/java/org/xbib/content/xml/XmlXContent.java index 2c81ab4..2668f00 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/XmlXContent.java +++ b/content-xml/src/main/java/org/xbib/content/xml/XmlXContent.java @@ -22,7 +22,7 @@ public class XmlXContent implements XContent { private static XmlXContent xmlXContent; - private XmlFactory xmlFactory; + private final XmlFactory xmlFactory; /** * Public constructor, used by {@link java.util.ServiceLoader}. diff --git a/content-yaml/build.gradle b/content-yaml/build.gradle index 3bc02b3..68968f0 100644 --- a/content-yaml/build.gradle +++ b/content-yaml/build.gradle @@ -1,4 +1,5 @@ dependencies { api project(':content-core') api "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${project.property('jackson.version')}" + api "org.yaml:snakeyaml:${project.property('snakeyaml.version')}" } diff --git a/content-yaml/src/main/java/module-info.java b/content-yaml/src/main/java/module-info.java index e8dcf14..e8e47f3 100644 --- a/content-yaml/src/main/java/module-info.java +++ b/content-yaml/src/main/java/module-info.java @@ -1,7 +1,7 @@ module org.xbib.content.yaml { exports org.xbib.content.yaml; - requires org.xbib.content.core; - requires com.fasterxml.jackson.dataformat.yaml; + requires transitive org.xbib.content.core; + requires transitive com.fasterxml.jackson.dataformat.yaml; provides org.xbib.content.XContent with org.xbib.content.yaml.YamlXContent; provides org.xbib.content.settings.SettingsLoader with diff --git a/gradle.properties b/gradle.properties index a86e661..d6559ac 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,12 @@ group = org.xbib name = content -version = 2.2.0 +version = 2.3.0 gradle.wrapper.version = 6.4.1 xbib.net.version = 2.0.4 -jackson.version = 2.9.10 -jackson.databind.version = 2.9.10.1 +jackson.version = 2.11.0 +jackson.databind.version = 2.11.0 woodstox.version = 6.2.1 -mockito.version = 3.1.0 -junit4.version = 4.13 +snakeyaml.version = 1.26 +mockito.version = 3.3.3 asciidoclet.version = 1.5.6 diff --git a/gradle/compile/java.gradle b/gradle/compile/java.gradle index 7b1e601..9c8798d 100644 --- a/gradle/compile/java.gradle +++ b/gradle/compile/java.gradle @@ -33,3 +33,11 @@ task javadocJar(type: Jar, dependsOn: javadoc) { artifacts { archives sourcesJar, javadocJar } + +tasks.withType(JavaCompile) { + options.compilerArgs << '-Xlint:all' +} + +javadoc { + options.addStringOption('Xdoclint:none', '-quiet') +} diff --git a/gradle/quality/checkstyle.gradle b/gradle/quality/checkstyle.gradle new file mode 100644 index 0000000..01a0c63 --- /dev/null +++ b/gradle/quality/checkstyle.gradle @@ -0,0 +1,27 @@ +apply plugin: 'checkstyle' + +checkstyle { + toolVersion '8.33' + showViolations = true + ignoreFailures = true + configFile rootProject.file("config/checkstyle/checkstyle.xml") +} + +checkstyleMain { + exclude "**/module-info.java" + logging.setLevel(LogLevel.LIFECYCLE) + source ='src/main/java' +} + +checkstyleTest { + exclude "**/module-info.java" + logging.setLevel(LogLevel.LIFECYCLE) + source ='src/test/java' +} + +tasks.withType(Checkstyle) { + reports { + xml.enabled false + html.enabled true + } +} \ No newline at end of file diff --git a/gradle/quality/pmd.gradle b/gradle/quality/pmd.gradle new file mode 100644 index 0000000..5a2092c --- /dev/null +++ b/gradle/quality/pmd.gradle @@ -0,0 +1,9 @@ +apply plugin: 'pmd' + +pmd { + ignoreFailures = true + consoleOutput = false + toolVersion = "6.24.0" + rulePriority = 5 + ruleSets = ["category/java/errorprone.xml", "category/java/bestpractices.xml"] +} diff --git a/gradle/quality/spotbugs.gradle b/gradle/quality/spotbugs.gradle new file mode 100644 index 0000000..2b9e2cf --- /dev/null +++ b/gradle/quality/spotbugs.gradle @@ -0,0 +1,18 @@ +apply plugin: "com.github.spotbugs" + +spotbugs { + ignoreFailures = true +} + +spotbugsMain { + reports { + html { + enabled = true + destination = file("$buildDir/reports/spotbugs/main/spotbugs.html") + } + } +} + +spotbugsTest { + enabled = false +}