Add build config for Gson subset#2947
Conversation
eamonnmcmanus
left a comment
There was a problem hiding this comment.
Thanks for doing this, it is great!
Just a couple of things.
gson/pom.xml
Outdated
| <include>com/google/gson/JsonSyntaxException.java</include> | ||
| <!-- Type adapter, serializer and deserializer --> | ||
| <include>com/google/gson/TypeAdapter.java</include> | ||
| <include>com/google/gson/JsonSerializer.java</include> |
There was a problem hiding this comment.
I did not find I needed to include JsonSerializer and JsonSerializationContext in the subset we're using internally at Google. Are they needed here for some reason?
There was a problem hiding this comment.
No, I just guessed the subset. I have also removed JsonDeserializer and JsonDeserializationContext now. I hope the list now matches what you are using.
There was a problem hiding this comment.
Weird, I was sure I had commented with the exact list of source files that we're including internally, but I don't see my comment. Here it is again:
gson/src/main/java/com/google/gson/FormattingStyle.java
gson/src/main/java/com/google/gson/JsonArray.java
gson/src/main/java/com/google/gson/JsonElement.java
gson/src/main/java/com/google/gson/JsonIOException.java
gson/src/main/java/com/google/gson/JsonNull.java
gson/src/main/java/com/google/gson/JsonObject.java
gson/src/main/java/com/google/gson/JsonParseException.java
gson/src/main/java/com/google/gson/JsonParser.java
gson/src/main/java/com/google/gson/JsonPrimitive.java
gson/src/main/java/com/google/gson/JsonStreamParser.java
gson/src/main/java/com/google/gson/JsonSyntaxException.java
gson/src/main/java/com/google/gson/LongSerializationPolicy.java
gson/src/main/java/com/google/gson/Strictness.java
gson/src/main/java/com/google/gson/TypeAdapter.java
gson/src/main/java/com/google/gson/internal/JsonReaderInternalAccess.java
gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java
gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java
gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java
gson/src/main/java/com/google/gson/internal/NumberLimits.java
gson/src/main/java/com/google/gson/internal/Streams.java
gson/src/main/java/com/google/gson/internal/TroubleshootingGuide.java
gson/src/main/java/com/google/gson/internal/bind/JsonElementTypeAdapter.java
gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java
gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java
gson/src/main/java/com/google/gson/package-info.java
gson/src/main/java/com/google/gson/stream/JsonReader.java
gson/src/main/java/com/google/gson/stream/JsonScope.java
gson/src/main/java/com/google/gson/stream/JsonToken.java
gson/src/main/java/com/google/gson/stream/JsonWriter.java
gson/src/main/java/com/google/gson/stream/MalformedJsonException.java
In particular, yes, it does include JsonParser.
There was a problem hiding this comment.
Also, in the comment that I remember writing but don't see, I mentioned that I wasn't sure that LongSerializationPolicy belonged in the list, since I don't think you can use it without also using the Gson class.
There was a problem hiding this comment.
Have adjusted the list of classes. But LongSerializationPolicy indeed only seems to be relevant for Gson / GsonBuilder, so I have omitted it.
eamonnmcmanus
left a comment
There was a problem hiding this comment.
Would it be possible too to run SubsetTest against the copied subset of sources?
gson/pom.xml
Outdated
| <!-- Use custom output directory to avoid interfering with normal Gson build --> | ||
| <outputDirectory>${project.build.directory}/gson-subset-classes</outputDirectory> |
There was a problem hiding this comment.
Have removed this again because otherwise the test compilation cannot see these classes, and it looks like at least maven-compiler-plugin itself does not support extending the classpath? (could maybe be done through external plugins, but not sure if that is worth it)
I guess this is not an issue as long as you always run mvn clean ... to be safe, respectively don't cache the target/ dir in CI.
Have adjusted the PR with one possible solution for this, and have included some of the other tests as well. I hope that is ok and useful; if not I can limit it to I also made some small changes because I am not that sure though how useful it is to run the tests for the subset, given that the regular Gson build runs these tests as well. I guess most issues would already pop up during the compilation of the subset. This subset build config feels rather brittle (I think it would also not notice non-existent |
Yes, we also do that internally, with a fairly random selection of tests. The one that matters is |
1fa979e to
0d604cf
Compare
| <testInclude>com/google/gson/JsonParserParameterizedTest.java</testInclude> | ||
| <testInclude>com/google/gson/JsonPrimitiveTest.java</testInclude> | ||
| <testInclude>com/google/gson/JsonStreamParserTest.java</testInclude> |
There was a problem hiding this comment.
Can't include JsonParserTest because its testReadWriteTwoObjects method uses Gson and refers to TestTypes, which uses a lot of Gson classes not included in the subset.
eamonnmcmanus
left a comment
There was a problem hiding this comment.
Great, thanks again! Is this ready to be merged?
|
Yes I think so, if the list of classes and tests is fine for you like this. As side note: For the Footnotes
|
Yeah, that doesn't seem problematic to me. |
Purpose
Follow-up for #2946
Adds a build config which builds the Gson API subset, so that any changes which break this can be directly noticed.
Description
The Maven config is unfortunately a bit verbose because:
target/classesSee also the comments in the changed code. Any hints on how this can be simplified are welcome.
As requested in #2946 (comment), the new GitHub workflow job will cause a workflow failure when building the Gson API subset fails.