From cc505e1b9fa6e6e29466914a348315f73d326d27 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sun, 7 Nov 2021 17:42:08 +0100 Subject: [PATCH] Convert codegen, metrics and proto to Maven submodules (#2008) * Convert codegen, metrics and proto to Maven submodules * Fix import order --- codegen/pom.xml | 172 ++++----------- extras/pom.xml | 2 - gson/pom.xml | 33 +++ metrics/pom.xml | 139 ++++-------- .../google/gson/metrics/ParseBenchmark.java | 34 +-- pom.xml | 32 +-- proto/pom.xml | 198 ++++-------------- .../{protobuf => proto}/annotations.proto | 0 proto/src/main/{protobuf => proto}/bag.proto | 2 + 9 files changed, 180 insertions(+), 432 deletions(-) rename proto/src/main/{protobuf => proto}/annotations.proto (100%) rename proto/src/main/{protobuf => proto}/bag.proto (99%) diff --git a/codegen/pom.xml b/codegen/pom.xml index cee611ab..7b26e8af 100644 --- a/codegen/pom.xml +++ b/codegen/pom.xml @@ -1,170 +1,76 @@ 4.0.0 - com.google.code.gson + + com.google.code.gson + gson-parent + 2.9.0-SNAPSHOT + + gson-codegen - jar - 1.0-SNAPSHOT 2008 Gson Code Gen - - org.sonatype.oss - oss-parent - 7 - - http://code.google.com/p/google-gson/ Google Gson grab bag of utilities, type adapters, etc. - - UTF-8 - + - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo + Apache-2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt - - scm:svn:http://google-gson.googlecode.com/svn/trunk/extras - scm:svn:https://google-gson.googlecode.com/svn/trunk/extras - http://google-gson.codegoogle.com/svn/trunk/extras - - - Google Code Issue Tracking - http://code.google.com/p/google-gson/issues/list - + Google, Inc. - http://www.google.com + https://www.google.com + junit junit - 4.13.1 test - - - - release-sign-artifacts - - - performRelease - true - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.4 - - - sign-artifacts - verify - - sign - - - - - - - - + - package org.apache.maven.plugins maven-compiler-plugin - 2.5.1 - - 1.6 - 1.6 - -proc:none - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 + - package + default-compile + + -proc:none + + + + compile-project + compile - jar + compile - - - false - - - - - org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - - attach-sources - verify - - jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.8.1 - - - attach-javadocs - - jar - - - - - - http://download.oracle.com/javase/1.5.0/docs/api/ - - true - public - - - - org.apache.maven.plugins - maven-eclipse-plugin - 2.9 - - true - true - - ../eclipse-ws/ - - - file:///${basedir}/../lib/gson-formatting-styles.xml - - - - - org.apache.maven.plugins - maven-release-plugin - - - -DenableCiProfile=true - https://google-gson.googlecode.com/svn/tags/ - + + + + + org.apache.maven.plugins + maven-deploy-plugin + 3.0.0-M1 + + + true + + + + + Inderjeet Singh diff --git a/extras/pom.xml b/extras/pom.xml index 2cef36ef..7215136f 100644 --- a/extras/pom.xml +++ b/extras/pom.xml @@ -7,8 +7,6 @@ gson-extras - jar - 2.9.0-SNAPSHOT 2008 Gson Extras Google Gson grab bag of utilities, type adapters, etc. diff --git a/gson/pom.xml b/gson/pom.xml index d9d37baa..21e80e69 100644 --- a/gson/pom.xml +++ b/gson/pom.xml @@ -31,6 +31,39 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + + default-compile + + + 9 + + 9 + + + + base-compile + + compile + + + + module-info.java + + + + + + + [1.5,9) + + 1.6 + 1.6 + + org.apache.maven.plugins maven-javadoc-plugin diff --git a/metrics/pom.xml b/metrics/pom.xml index 79641a55..bd04d4f8 100644 --- a/metrics/pom.xml +++ b/metrics/pom.xml @@ -1,129 +1,64 @@ - 4.0.0 - com.google.code.gson + + com.google.code.gson + gson-parent + 2.9.0-SNAPSHOT + + gson-metrics - jar - 1.0-SNAPSHOT 2011 Gson Metrics - - org.sonatype.oss - oss-parent - 5 - - http://code.google.com/p/google-gson/ Performance Metrics for Google Gson library - - UTF-8 - + - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo + Apache-2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt - - scm:svn:http://google-gson.googlecode.com/svn/trunk/metrics - scm:svn:https://google-gson.googlecode.com/svn/trunk/metrics - http://google-gson.codegoogle.com/svn/trunk/metrics - - - Google Code Issue Tracking - http://code.google.com/p/google-gson/issues/list - + Google, Inc. - http://www.google.com + https://www.google.com + com.google.code.gson gson - 1.7.2-SNAPSHOT + ${project.parent.version} - com.google.code.caliper + com.fasterxml.jackson.core + jackson-databind + 2.13.0 + + + com.google.caliper caliper - 1.0-SNAPSHOT - - - junit - junit - 4.13.1 - test + 0.5-rc1 + - package - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - - - - org.apache.maven.plugins - maven-eclipse-plugin - 2.8 - - true - true - ../eclipse-ws/ - - file:///${basedir}/../lib/gson-formatting-styles.xml - - - - - org.apache.maven.plugins - maven-release-plugin - 2.1 - - -DenableCiProfile=true - https://google-gson.googlecode.com/svn/tags/ - - - - org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.7 - - - attach-javadocs - - jar - - - - - - http://download.oracle.com/javase/1.5.0/docs/api/ - - true - public - - - + + + + org.apache.maven.plugins + maven-deploy-plugin + 3.0.0-M1 + + + true + + + + + Inderjeet Singh diff --git a/metrics/src/main/java/com/google/gson/metrics/ParseBenchmark.java b/metrics/src/main/java/com/google/gson/metrics/ParseBenchmark.java index 68134372..a9e0f4e2 100644 --- a/metrics/src/main/java/com/google/gson/metrics/ParseBenchmark.java +++ b/metrics/src/main/java/com/google/gson/metrics/ParseBenchmark.java @@ -16,6 +16,14 @@ package com.google.gson.metrics; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonFactoryBuilder; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.json.JsonMapper; import com.google.caliper.Param; import com.google.caliper.Runner; import com.google.caliper.SimpleBenchmark; @@ -34,11 +42,6 @@ import java.lang.reflect.Type; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; -import org.codehaus.jackson.JsonFactory; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.type.TypeReference; /** * Measure Gson and Jackson parsing and binding performance. @@ -139,6 +142,7 @@ public final class ParseBenchmark extends SimpleBenchmark { } private static class GsonStreamParser implements Parser { + @Override public void parse(char[] data, Document document) throws Exception { com.google.gson.stream.JsonReader jsonReader = new com.google.gson.stream.JsonReader(new CharArrayReader(data)); @@ -186,6 +190,7 @@ public final class ParseBenchmark extends SimpleBenchmark { } private static class GsonSkipParser implements Parser { + @Override public void parse(char[] data, Document document) throws Exception { com.google.gson.stream.JsonReader jsonReader = new com.google.gson.stream.JsonReader(new CharArrayReader(data)); @@ -195,10 +200,10 @@ public final class ParseBenchmark extends SimpleBenchmark { } private static class JacksonStreamParser implements Parser { + @Override public void parse(char[] data, Document document) throws Exception { - JsonFactory jsonFactory = new JsonFactory(); - org.codehaus.jackson.JsonParser jp = jsonFactory.createJsonParser(new CharArrayReader(data)); - jp.configure(org.codehaus.jackson.JsonParser.Feature.CANONICALIZE_FIELD_NAMES, false); + JsonFactory jsonFactory = new JsonFactoryBuilder().configure(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES, false).build(); + com.fasterxml.jackson.core.JsonParser jp = jsonFactory.createParser(new CharArrayReader(data)); int depth = 0; do { switch (jp.nextToken()) { @@ -227,8 +232,9 @@ public final class ParseBenchmark extends SimpleBenchmark { } private static class GsonDomParser implements Parser { + @Override public void parse(char[] data, Document document) throws Exception { - new JsonParser().parse(new CharArrayReader(data)); + JsonParser.parseReader(new CharArrayReader(data)); } } @@ -237,20 +243,24 @@ public final class ParseBenchmark extends SimpleBenchmark { .setDateFormat("EEE MMM dd HH:mm:ss Z yyyy") .create(); + @Override public void parse(char[] data, Document document) throws Exception { gson.fromJson(new CharArrayReader(data), document.gsonType); } } private static class JacksonBindParser implements Parser { - private static ObjectMapper mapper = new ObjectMapper(); + private static final ObjectMapper mapper; static { - mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationConfig.Feature.AUTO_DETECT_FIELDS, true); + mapper = JsonMapper.builder() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .configure(MapperFeature.AUTO_DETECT_FIELDS, true) + .build(); mapper.setDateFormat(new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy")); } + @Override public void parse(char[] data, Document document) throws Exception { mapper.readValue(new CharArrayReader(data), document.jacksonType); } diff --git a/pom.xml b/pom.xml index d0d45be9..5b2a3e1f 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,9 @@ gson extras + codegen + metrics + proto @@ -65,35 +68,6 @@ org.apache.maven.plugins maven-compiler-plugin 3.8.1 - - - default-compile - - - 9 - - 9 - - - - base-compile - - compile - - - - module-info.java - - - - - - - [1.5,9) - - 1.6 - 1.6 - org.apache.maven.plugins diff --git a/proto/pom.xml b/proto/pom.xml index afe55a1c..a5a4be91 100644 --- a/proto/pom.xml +++ b/proto/pom.xml @@ -4,82 +4,48 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.google.code.gson + + com.google.code.gson + gson-parent + 2.9.0-SNAPSHOT + + proto - jar - 0.6-SNAPSHOT Gson Protobuf Support Gson support for Protobufs - - UTF-8 - - - - local.repo - file repository to svn - file://${basedir}/../../mavenrepo - - - - - gson - http://google-gson.googlecode.com/svn/mavenrepo - - true - - - true - - - + - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo + Apache-2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt - - scm:svn:http://google-gson.googlecode.com/svn/trunk/proto - scm:svn:https://google-gson.googlecode.com/svn/trunk/proto - http://google-gson.codegoogle.com/svn/trunk/proto - - - Google Code Issue Tracking - http://code.google.com/p/google-gson/issues/list - - - com.google.code.gson gson - 2.8.9 - compile + ${project.parent.version} com.google.protobuf protobuf-java 4.0.0-rc-2 - compile - + com.google.guava guava 30.1.1-jre - compile junit junit - 4.13.2 test - + com.google.truth truth @@ -90,125 +56,49 @@ gson-proto + + + + kr.motd.maven + os-maven-plugin + 1.7.0 + + + - maven-antrun-plugin - 1.8 + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.6.1 + + com.google.protobuf:protoc:3.17.3:exe:${os.detected.classifier} + - compile-protoc - generate-sources - - - - - - - - - - - - - - - - - - run + compile + test-compile - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - - - - org.apache.maven.plugins - maven-eclipse-plugin - 2.8 - - true - true - ../eclipse-ws - file:///${basedir}/../lib/gson-formatting-styles.xml - - - - org.apache.maven.plugins - maven-install-plugin - 2.5.2 - - - - org.apache.maven.plugins - maven-release-plugin - 2.1 - - -DenableCiProfile=true - https://google-gson.googlecode.com/svn/tags/ - - - - org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.7 - - - attach-javadocs - - jar - - - - - - http://download.oracle.com/javase/1.5.0/docs/api/ - - true - public - - - - maven-assembly-plugin - - src/main/resources/assembly-descriptor.xml - proto-${project.version} - target/dist - target/assembly/work - - + + + + + org.apache.maven.plugins + maven-deploy-plugin + 3.0.0-M1 + + + true + + + + + Inderjeet Singh diff --git a/proto/src/main/protobuf/annotations.proto b/proto/src/main/proto/annotations.proto similarity index 100% rename from proto/src/main/protobuf/annotations.proto rename to proto/src/main/proto/annotations.proto diff --git a/proto/src/main/protobuf/bag.proto b/proto/src/main/proto/bag.proto similarity index 99% rename from proto/src/main/protobuf/bag.proto rename to proto/src/main/proto/bag.proto index 48cc9639..3e4769e2 100644 --- a/proto/src/main/protobuf/bag.proto +++ b/proto/src/main/proto/bag.proto @@ -14,6 +14,8 @@ // limitations under the License. // +syntax = "proto2"; + package google.gson.protobuf.generated; option java_package = "com.google.gson.protobuf.generated";