From fc79b90ea1ff412eb0fa139d379800a7cc90480d Mon Sep 17 00:00:00 2001 From: zml Date: Fri, 17 Dec 2021 21:44:52 -0800 Subject: [PATCH] yaml: Eclipse integration work --- .gitignore | 4 +++ buildSrc/build.gradle | 1 + ...powered.configurate.build.component.gradle | 1 + .../configurate/yaml/YamlTest.groovy | 31 ++++++++++--------- vendor/build.gradle.kts | 4 +-- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index e2534f021..be0bb9963 100644 --- a/.gitignore +++ b/.gitignore @@ -2,16 +2,20 @@ /*/build/ /*/out/ /*/bin/ +/*/.factorypath buildSrc/build/ buildSrc/out/ buildSrc/*/bin/ /build/ +buildSrc/build/ /format/*/bin/ /format/*/build/ /format/*/out/ +/format/*/.factorypath /extra/*/build/ /extra/*/out/ /extra/*/bin/ +/extra/*/.factorypath # gitpatcher local data /vendor/snakeyaml/ diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 6aea34760..72f0f1c91 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -36,5 +36,6 @@ dependencies { api "net.ltgt.gradle:gradle-nullaway-plugin:1.2.0" api "me.champeau.gradle:japicmp-gradle-plugin:0.3.0" api "de.thetaphi:forbiddenapis:3.2" + api "com.diffplug.gradle:goomph:3.34.0" implementation "com.google.guava:guava:31.0.1-jre" } diff --git a/buildSrc/src/main/groovy/org.spongepowered.configurate.build.component.gradle b/buildSrc/src/main/groovy/org.spongepowered.configurate.build.component.gradle index bc993bc49..5ceb1d9b1 100644 --- a/buildSrc/src/main/groovy/org.spongepowered.configurate.build.component.gradle +++ b/buildSrc/src/main/groovy/org.spongepowered.configurate.build.component.gradle @@ -17,6 +17,7 @@ plugins { id "me.champeau.gradle.japicmp" id "de.thetaphi.forbiddenapis" id 'pmd' + id 'com.diffplug.eclipse.apt' } configurations.configureEach { diff --git a/format/yaml/src/test/groovy/org/spongepowered/configurate/yaml/YamlTest.groovy b/format/yaml/src/test/groovy/org/spongepowered/configurate/yaml/YamlTest.groovy index cb8e7bbf7..c92588aff 100644 --- a/format/yaml/src/test/groovy/org/spongepowered/configurate/yaml/YamlTest.groovy +++ b/format/yaml/src/test/groovy/org/spongepowered/configurate/yaml/YamlTest.groovy @@ -23,19 +23,19 @@ import org.yaml.snakeyaml.parser.ParserImpl import org.yaml.snakeyaml.reader.StreamReader import org.yaml.snakeyaml.scanner.ScannerImpl -import java.nio.charset.StandardCharsets +trait YamlTest { -interface YamlTest { - - default CommentedConfigurationNode parseString(final String input) { + CommentedConfigurationNode parseString(final String input) { // Print events def scanner = new ScannerImpl(new StreamReader(input)) - scanner.emitComments = true + scanner.parseComments = true scanner.acceptTabs = true def parser = new ParserImpl(scanner) - do { + + while (true) { println parser.getEvent() - } while (parser.peekEvent()) + if (!parser.peekEvent()) break + } final YamlParserComposer loader = new YamlParserComposer(new StreamReader(input), Yaml11Tags.REPOSITORY, true) final CommentedConfigurationNode result = CommentedConfigurationNode.root() @@ -43,20 +43,21 @@ interface YamlTest { return result } - default CommentedConfigurationNode parseResource(final URL url) { + CommentedConfigurationNode parseResource(final URL url) { // Print events url.openStream().withReader('UTF-8') {reader -> def scanner = new ScannerImpl(new StreamReader(reader)) - scanner.emitComments = true + scanner.parseComments = true scanner.acceptTabs = true def parser = new ParserImpl(scanner) - do { + while (true) { println parser.getEvent() - } while (parser.peekEvent()) + if (!parser.peekEvent()) break + } } assertNotNull(url, "Expected resource is missing") - try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8))) { + url.openStream().withReader('UTF-8') { reader -> final YamlParserComposer loader = new YamlParserComposer(new StreamReader(reader), Yaml11Tags.REPOSITORY, true) final CommentedConfigurationNode result = CommentedConfigurationNode.root() loader.singleDocumentStream(result) @@ -64,11 +65,11 @@ interface YamlTest { } } - default String dump(final CommentedConfigurationNode input) { + String dump(final CommentedConfigurationNode input) { return dump(input, null) } - default String dump(final CommentedConfigurationNode input, final NodeStyle preferredStyle) { + String dump(final CommentedConfigurationNode input, final NodeStyle preferredStyle) { return YamlConfigurationLoader.builder() .nodeStyle(preferredStyle) .indent(2) @@ -76,7 +77,7 @@ interface YamlTest { .buildAndSaveString(input) } - default String normalize(final String input) { + String normalize(final String input) { return input.stripIndent(true) } diff --git a/vendor/build.gradle.kts b/vendor/build.gradle.kts index 05d0b591e..1d6bf54f2 100644 --- a/vendor/build.gradle.kts +++ b/vendor/build.gradle.kts @@ -71,10 +71,10 @@ project(":snakeyaml") { val applyPatches = rootProject.tasks.named("applyPatches") tasks.withType(JavaCompile::class) { options.release.set(7) - dependsOn(applyPatches) + // dependsOn(applyPatches) } tasks.withType(ProcessResources::class) { - dependsOn(applyPatches) + // dependsOn(applyPatches) } tasks.named("test", Test::class) {