From a86f142563af15ff654efbd3d9dbea7f124d365b Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sat, 1 Oct 2022 00:04:51 +0200 Subject: [PATCH 1/3] Automatically replace version references on `release:prepare` --- ReleaseProcess.md | 5 +- gson/src/main/java/com/google/gson/Gson.java | 5 +- pom.xml | 72 ++++++++++++++++++++ 3 files changed, 80 insertions(+), 2 deletions(-) diff --git a/ReleaseProcess.md b/ReleaseProcess.md index 6e2b923d24..eaa0e7c542 100644 --- a/ReleaseProcess.md +++ b/ReleaseProcess.md @@ -6,7 +6,6 @@ The following is a step-by-step procedure for releasing a new version of Google- 1. Ensure all changelists are code-reviewed and have +1 1. `cd gson` to the parent directory; ensure there are no open files and all changes are committed. 1. Run `mvn release:clean` -1. Do a dry run: `mvn release:prepare -DdryRun=true` 1. Start the release: `mvn release:prepare` - Answer questions: usually the defaults are fine. Try to follow [Semantic Versioning](https://semver.org/) when choosing the release version number. - This will do a full build, change version from `-SNAPSHOT` to the released version, commit and create the tags. It will then change the version to `-SNAPSHOT` for the next release. @@ -18,9 +17,13 @@ The following is a step-by-step procedure for releasing a new version of Google- 1. Update version references in (version might be referenced multiple times): - [`README.md`](README.md) - [`UserGuide.md`](UserGuide.md) + + Note: When using the Maven Release Plugin as described above, these version references should have been replaced automatically, but verify this manually nonetheless to be on the safe side. 1. Optional: Create a post on the [Gson Discussion Forum](https://groups.google.com/group/google-gson). 1. Optional: Update the release version in [Wikipedia](https://en.wikipedia.org/wiki/Gson) and update the current "stable" release. +Important: When aborting a release / rolling back release preparations, make sure to also revert all changes to files which were done during the release (e.g. automatic replacement of version references). + ## Configuring a machine for deployment to Sonatype Repository This section was borrowed heavily from [Doclava release process](https://code.google.com/archive/p/doclava/wikis/ProcessRelease.wiki). diff --git a/gson/src/main/java/com/google/gson/Gson.java b/gson/src/main/java/com/google/gson/Gson.java index c3262a6fe0..afab5fae78 100644 --- a/gson/src/main/java/com/google/gson/Gson.java +++ b/gson/src/main/java/com/google/gson/Gson.java @@ -1019,6 +1019,7 @@ public T fromJson(String json, Type typeOfT) throws JsonSyntaxException { * * @see #fromJson(Reader, TypeToken) * @see #fromJson(String, Class) + * @since $next-version$ */ public T fromJson(String json, TypeToken typeOfT) throws JsonSyntaxException { if (json == null) { @@ -1111,6 +1112,7 @@ public T fromJson(Reader json, Type typeOfT) throws JsonIOException, JsonSyn * * @see #fromJson(String, TypeToken) * @see #fromJson(Reader, Class) + * @since $next-version$ */ public T fromJson(Reader json, TypeToken typeOfT) throws JsonIOException, JsonSyntaxException { JsonReader jsonReader = newJsonReader(json); @@ -1194,6 +1196,7 @@ public T fromJson(JsonReader reader, Type typeOfT) throws JsonIOException, J * * @see #fromJson(Reader, TypeToken) * @see #fromJson(JsonReader, Type) + * @since $next-version$ */ public T fromJson(JsonReader reader, TypeToken typeOfT) throws JsonIOException, JsonSyntaxException { boolean isEmpty = true; @@ -1299,10 +1302,10 @@ public T fromJson(JsonElement json, Type typeOfT) throws JsonSyntaxException * @return an object of type T from the JSON. Returns {@code null} if {@code json} is {@code null} * or if {@code json} is empty. * @throws JsonSyntaxException if json is not a valid representation for an object of type typeOfT - * @since 1.3 * * @see #fromJson(Reader, TypeToken) * @see #fromJson(JsonElement, Class) + * @since $next-version$ */ public T fromJson(JsonElement json, TypeToken typeOfT) throws JsonSyntaxException { if (json == null) { diff --git a/pom.xml b/pom.xml index b732767647..83a0319d6f 100644 --- a/pom.xml +++ b/pom.xml @@ -136,8 +136,80 @@ false release + + + + package -DskipTests + antrun:run@replace-version-placeholders + antrun:run@replace-old-version-references + antrun:run@git-add-changed + + + maven-antrun-plugin + 3.1.0 + + + + replace-version-placeholders + + run + + + + false + + + + + + + + replace-old-version-references + + run + + + + + + + + + + + + + + + false + + + + + git-add-changed + + run + + + + + + + + + + + + com.github.siom79.japicmp From 27a19f0cd645dfb80da0c6dd5ddeb8a451f4b39b Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sat, 1 Oct 2022 04:45:08 +0200 Subject: [PATCH 2/3] Specify encoding and improve placeholder replacements --- pom.xml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 83a0319d6f..140ab0d3a2 100644 --- a/pom.xml +++ b/pom.xml @@ -159,11 +159,11 @@ run - - false - + + + + @@ -176,12 +176,12 @@ - - - - - - + + + + + + From 55f4bb7f29e87bdff024c5c46a0377f5e5ba77d9 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sat, 22 Oct 2022 13:59:26 +0200 Subject: [PATCH 3/3] Add `since $next-version$` for `JsonArray.asList` and `JsonObject.asMap` --- gson/src/main/java/com/google/gson/JsonArray.java | 1 + gson/src/main/java/com/google/gson/JsonObject.java | 1 + 2 files changed, 2 insertions(+) diff --git a/gson/src/main/java/com/google/gson/JsonArray.java b/gson/src/main/java/com/google/gson/JsonArray.java index e9ce580c68..fadc76641c 100644 --- a/gson/src/main/java/com/google/gson/JsonArray.java +++ b/gson/src/main/java/com/google/gson/JsonArray.java @@ -406,6 +406,7 @@ public boolean getAsBoolean() { * Use {@link JsonNull} for JSON null values. * * @return mutable {@code List} view + * @since $next-version$ */ public List asList() { return new NonNullElementWrapperList<>(elements); diff --git a/gson/src/main/java/com/google/gson/JsonObject.java b/gson/src/main/java/com/google/gson/JsonObject.java index 0c36ef24b3..d1c6b30b64 100644 --- a/gson/src/main/java/com/google/gson/JsonObject.java +++ b/gson/src/main/java/com/google/gson/JsonObject.java @@ -220,6 +220,7 @@ public JsonObject getAsJsonObject(String memberName) { * Use {@link JsonNull} for JSON null values. * * @return mutable {@code Map} view + * @since $next-version$ */ public Map asMap() { // It is safe to expose the underlying map because it disallows null keys and values