Blame SOURCES/no-templating-maven-plugin.patch

a737bc
diff --git a/gson/pom.xml b/gson/pom.xml
a737bc
index ffe41ac..5ce5d96 100644
a737bc
--- a/gson/pom.xml
a737bc
+++ b/gson/pom.xml
a737bc
@@ -56,23 +56,6 @@
a737bc
         <groupId>org.apache.felix</groupId>
a737bc
         <artifactId>maven-bundle-plugin</artifactId>
a737bc
       </plugin>
a737bc
-      <plugin>
a737bc
-        <groupId>org.codehaus.mojo</groupId>
a737bc
-        <artifactId>templating-maven-plugin</artifactId>
a737bc
-        <version>1.0.0</version>
a737bc
-        <executions>
a737bc
-          <execution>
a737bc
-            <id>filtering-java-templates</id>
a737bc
-            <goals>
a737bc
-              <goal>filter-sources</goal>
a737bc
-            </goals>
a737bc
-            <configuration>
a737bc
-              <sourceDirectory>${basedir}/src/main/java-templates</sourceDirectory>
a737bc
-              <outputDirectory>${project.build.directory}/generated-sources/java-templates</outputDirectory>
a737bc
-            </configuration>
a737bc
-          </execution>
a737bc
-        </executions>
a737bc
-      </plugin>
a737bc
     </plugins>
a737bc
   </build>
a737bc
 </project>
a737bc
diff --git a/gson/src/main/java-templates/com/google/gson/internal/GsonBuildConfig.java b/gson/src/main/java-templates/com/google/gson/internal/GsonBuildConfig.java
a737bc
deleted file mode 100644
a737bc
index a94c96b..0000000
a737bc
--- a/gson/src/main/java-templates/com/google/gson/internal/GsonBuildConfig.java
a737bc
+++ /dev/null
a737bc
@@ -1,32 +0,0 @@
a737bc
-/*
a737bc
- * Copyright (C) 2018 The Gson authors
a737bc
- *
a737bc
- * Licensed under the Apache License, Version 2.0 (the "License");
a737bc
- * you may not use this file except in compliance with the License.
a737bc
- * You may obtain a copy of the License at
a737bc
- *
a737bc
- * http://www.apache.org/licenses/LICENSE-2.0
a737bc
- *
a737bc
- * Unless required by applicable law or agreed to in writing, software
a737bc
- * distributed under the License is distributed on an "AS IS" BASIS,
a737bc
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
a737bc
- * See the License for the specific language governing permissions and
a737bc
- * limitations under the License.
a737bc
- */
a737bc
-
a737bc
-package com.google.gson.internal;
a737bc
-
a737bc
-/**
a737bc
- * Build configuration for Gson. This file is automatically populated by
a737bc
- * templating-maven-plugin and .java/.class files are generated for use in Gson.
a737bc
- *
a737bc
- * @author Inderjeet Singh
a737bc
- */
a737bc
-public final class GsonBuildConfig {
a737bc
-  // Based on https://stackoverflow.com/questions/2469922/generate-a-version-java-file-in-maven
a737bc
-
a737bc
-  /** This field is automatically populated by Maven when a build is triggered */
a737bc
-  public static final String VERSION = "${project.version}";
a737bc
-
a737bc
-  private GsonBuildConfig() { }
a737bc
-}
a737bc
diff --git a/gson/src/main/java/com/google/gson/Gson.java b/gson/src/main/java/com/google/gson/Gson.java
a737bc
index 27f3ee9..d584ece 100644
a737bc
--- a/gson/src/main/java/com/google/gson/Gson.java
a737bc
+++ b/gson/src/main/java/com/google/gson/Gson.java
a737bc
@@ -37,7 +37,6 @@ import java.util.concurrent.atomic.AtomicLongArray;
a737bc
 
a737bc
 import com.google.gson.internal.ConstructorConstructor;
a737bc
 import com.google.gson.internal.Excluder;
a737bc
-import com.google.gson.internal.GsonBuildConfig;
a737bc
 import com.google.gson.internal.Primitives;
a737bc
 import com.google.gson.internal.Streams;
a737bc
 import com.google.gson.internal.bind.ArrayTypeAdapter;
a737bc
@@ -462,7 +461,7 @@ public final class Gson {
a737bc
           return candidate;
a737bc
         }
a737bc
       }
a737bc
-      throw new IllegalArgumentException("GSON (" + GsonBuildConfig.VERSION + ") cannot handle " + type);
a737bc
+      throw new IllegalArgumentException("GSON cannot handle " + type);
a737bc
     } finally {
a737bc
       threadCalls.remove(type);
a737bc
 
a737bc
@@ -704,10 +703,6 @@ public final class Gson {
a737bc
       ((TypeAdapter<Object>) adapter).write(writer, src);
a737bc
     } catch (IOException e) {
a737bc
       throw new JsonIOException(e);
a737bc
-    } catch (AssertionError e) {
a737bc
-      AssertionError error = new AssertionError("AssertionError (GSON " + GsonBuildConfig.VERSION + "): " + e.getMessage());
a737bc
-      error.initCause(e);
a737bc
-      throw error;
a737bc
     } finally {
a737bc
       writer.setLenient(oldLenient);
a737bc
       writer.setHtmlSafe(oldHtmlSafe);
a737bc
@@ -784,10 +779,6 @@ public final class Gson {
a737bc
       Streams.write(jsonElement, writer);
a737bc
     } catch (IOException e) {
a737bc
       throw new JsonIOException(e);
a737bc
-    } catch (AssertionError e) {
a737bc
-      AssertionError error = new AssertionError("AssertionError (GSON " + GsonBuildConfig.VERSION + "): " + e.getMessage());
a737bc
-      error.initCause(e);
a737bc
-      throw error;
a737bc
     } finally {
a737bc
       writer.setLenient(oldLenient);
a737bc
       writer.setHtmlSafe(oldHtmlSafe);
a737bc
@@ -945,10 +936,6 @@ public final class Gson {
a737bc
     } catch (IOException e) {
a737bc
       // TODO(inder): Figure out whether it is indeed right to rethrow this as JsonSyntaxException
a737bc
       throw new JsonSyntaxException(e);
a737bc
-    } catch (AssertionError e) {
a737bc
-      AssertionError error = new AssertionError("AssertionError (GSON " + GsonBuildConfig.VERSION + "): " + e.getMessage());
a737bc
-      error.initCause(e);
a737bc
-      throw error;
a737bc
     } finally {
a737bc
       reader.setLenient(oldLenient);
a737bc
     }
a737bc
diff --git a/gson/src/test/java/com/google/gson/functional/GsonVersionDiagnosticsTest.java b/gson/src/test/java/com/google/gson/functional/GsonVersionDiagnosticsTest.java
a737bc
deleted file mode 100644
a737bc
index 36eff8e..0000000
a737bc
--- a/gson/src/test/java/com/google/gson/functional/GsonVersionDiagnosticsTest.java
a737bc
+++ /dev/null
a737bc
@@ -1,96 +0,0 @@
a737bc
-/*
a737bc
- * Copyright (C) 2018 Gson Authors
a737bc
- *
a737bc
- * Licensed under the Apache License, Version 2.0 (the "License");
a737bc
- * you may not use this file except in compliance with the License.
a737bc
- * You may obtain a copy of the License at
a737bc
- *
a737bc
- * http://www.apache.org/licenses/LICENSE-2.0
a737bc
- *
a737bc
- * Unless required by applicable law or agreed to in writing, software
a737bc
- * distributed under the License is distributed on an "AS IS" BASIS,
a737bc
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
a737bc
- * See the License for the specific language governing permissions and
a737bc
- * limitations under the License.
a737bc
- */
a737bc
-package com.google.gson.functional;
a737bc
-
a737bc
-import java.io.IOException;
a737bc
-import java.util.regex.Pattern;
a737bc
-
a737bc
-import org.junit.Before;
a737bc
-import org.junit.Test;
a737bc
-
a737bc
-import com.google.gson.Gson;
a737bc
-import com.google.gson.GsonBuilder;
a737bc
-import com.google.gson.TypeAdapter;
a737bc
-import com.google.gson.stream.JsonReader;
a737bc
-import com.google.gson.stream.JsonWriter;
a737bc
-
a737bc
-import junit.framework.TestCase;
a737bc
-
a737bc
-/**
a737bc
- * Functional tests to validate printing of Gson version on AssertionErrors
a737bc
- *
a737bc
- * @author Inderjeet Singh
a737bc
- */
a737bc
-public class GsonVersionDiagnosticsTest extends TestCase {
a737bc
-  private static final Pattern GSON_VERSION_PATTERN = Pattern.compile("(\\(GSON \\d\\.\\d\\.\\d)(?:[-.][A-Z]+)?\\)$");
a737bc
-
a737bc
-  private Gson gson;
a737bc
-
a737bc
-  @Before
a737bc
-  public void setUp() {
a737bc
-    gson = new GsonBuilder().registerTypeAdapter(TestType.class, new TypeAdapter<TestType>() {
a737bc
-      @Override public void write(JsonWriter out, TestType value) {
a737bc
-        throw new AssertionError("Expected during serialization");
a737bc
-      }
a737bc
-      @Override public TestType read(JsonReader in) throws IOException {
a737bc
-        throw new AssertionError("Expected during deserialization");
a737bc
-      }
a737bc
-    }).create();
a737bc
-  }
a737bc
-
a737bc
-  @Test
a737bc
-  public void testVersionPattern() {
a737bc
-    assertTrue(GSON_VERSION_PATTERN.matcher("(GSON 2.8.5)").matches());
a737bc
-    assertTrue(GSON_VERSION_PATTERN.matcher("(GSON 2.8.5-SNAPSHOT)").matches());
a737bc
-  }
a737bc
-
a737bc
-  @Test
a737bc
-  public void testAssertionErrorInSerializationPrintsVersion() {
a737bc
-    try {
a737bc
-      gson.toJson(new TestType());
a737bc
-      fail();
a737bc
-    } catch (AssertionError expected) {
a737bc
-      ensureAssertionErrorPrintsGsonVersion(expected);
a737bc
-    }
a737bc
-  }
a737bc
-
a737bc
-  @Test
a737bc
-  public void testAssertionErrorInDeserializationPrintsVersion() {
a737bc
-    try {
a737bc
-      gson.fromJson("{'a':'abc'}", TestType.class);
a737bc
-      fail();
a737bc
-    } catch (AssertionError expected) {
a737bc
-      ensureAssertionErrorPrintsGsonVersion(expected);
a737bc
-    }
a737bc
-  }
a737bc
-
a737bc
-  private void ensureAssertionErrorPrintsGsonVersion(AssertionError expected) {
a737bc
-    String msg = expected.getMessage();
a737bc
-    // System.err.println(msg);
a737bc
-    int start = msg.indexOf("(GSON");
a737bc
-    assertTrue(start > 0);
a737bc
-    int end = msg.indexOf("):") + 1;
a737bc
-    assertTrue(end > 0 && end > start + 6);
a737bc
-    String version = msg.substring(start, end);
a737bc
-    // System.err.println(version);
a737bc
-    assertTrue(GSON_VERSION_PATTERN.matcher(version).matches());
a737bc
-  }
a737bc
-
a737bc
-  private static final class TestType {
a737bc
-    @SuppressWarnings("unused")
a737bc
-    String a;
a737bc
-  }
a737bc
-}
a737bc
diff --git a/gson/src/test/java/com/google/gson/internal/GsonBuildConfigTest.java b/gson/src/test/java/com/google/gson/internal/GsonBuildConfigTest.java
a737bc
deleted file mode 100644
a737bc
index dc39bc0..0000000
a737bc
--- a/gson/src/test/java/com/google/gson/internal/GsonBuildConfigTest.java
a737bc
+++ /dev/null
a737bc
@@ -1,33 +0,0 @@
a737bc
-/*
a737bc
- * Copyright (C) 2018 The Gson authors
a737bc
- *
a737bc
- * Licensed under the Apache License, Version 2.0 (the "License");
a737bc
- * you may not use this file except in compliance with the License.
a737bc
- * You may obtain a copy of the License at
a737bc
- *
a737bc
- * http://www.apache.org/licenses/LICENSE-2.0
a737bc
- *
a737bc
- * Unless required by applicable law or agreed to in writing, software
a737bc
- * distributed under the License is distributed on an "AS IS" BASIS,
a737bc
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
a737bc
- * See the License for the specific language governing permissions and
a737bc
- * limitations under the License.
a737bc
- */
a737bc
-package com.google.gson.internal;
a737bc
-
a737bc
-import static org.junit.Assert.assertFalse;
a737bc
-
a737bc
-import org.junit.Test;
a737bc
-
a737bc
-/**
a737bc
- * Unit tests for {@code GsonBuildConfig}
a737bc
- *
a737bc
- * @author Inderjeet Singh
a737bc
- */
a737bc
-public class GsonBuildConfigTest {
a737bc
-
a737bc
-  @Test
a737bc
-  public void testEnsureGsonBuildConfigGetsUpdatedToMavenVersion() {
a737bc
-    assertFalse("${project.version}".equals(GsonBuildConfig.VERSION));
a737bc
-  }
a737bc
-}