mirror of https://github.com/apache/jclouds.git
JCLOUDS-1166: Relocate the gson internal packge to be able to keep using it (#35)
* JCLOUDS-1166: Relocate the gson internal packge to be able to keep using it * Fixes * Fix import order and shaded jar * More fixes * Proper dependency configuration * Fix typos * Bring back duplicate exclusions
This commit is contained in:
parent
cd7b3b9b36
commit
b8606a10dd
|
@ -19,7 +19,10 @@ atlassian-ide-plugin.xml
|
|||
.java-version
|
||||
.factorypath
|
||||
.apt_generated
|
||||
.apt_generated_tests
|
||||
.checkstyle
|
||||
nb-configuration.xml
|
||||
nbactions.xml
|
||||
/.nb-gradle/
|
||||
dependency-reduced-pom.xml
|
||||
.vscode
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.jclouds.crypto.Crypto;
|
|||
import org.jclouds.crypto.Pems;
|
||||
import org.jclouds.json.config.GsonModule.DateAdapter;
|
||||
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
|
||||
import org.jclouds.json.gson.internal.JsonReaderInternalAccess;
|
||||
import org.jclouds.json.internal.NullFilteringTypeAdapterFactories;
|
||||
import org.jclouds.json.internal.NullFilteringTypeAdapterFactories.MapTypeAdapterFactory;
|
||||
import org.jclouds.json.internal.NullHackJsonLiteralAdapter;
|
||||
|
@ -53,7 +54,6 @@ import com.google.gson.JsonElement;
|
|||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.internal.JsonReaderInternalAccess;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.inject.AbstractModule;
|
||||
|
|
|
@ -78,9 +78,8 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.5</version>
|
||||
<groupId>org.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-gson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
|
|
|
@ -37,6 +37,9 @@ import org.jclouds.domain.JsonBall;
|
|||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.json.Json;
|
||||
import org.jclouds.json.SerializedNames;
|
||||
import org.jclouds.json.gson.internal.ConstructorConstructor;
|
||||
import org.jclouds.json.gson.internal.Excluder;
|
||||
import org.jclouds.json.gson.internal.JsonReaderInternalAccess;
|
||||
import org.jclouds.json.internal.DeserializationConstructorAndReflectiveTypeAdapterFactory;
|
||||
import org.jclouds.json.internal.EnumTypeAdapterThatReturnsFromValue;
|
||||
import org.jclouds.json.internal.GsonWrapper;
|
||||
|
@ -71,9 +74,6 @@ import com.google.gson.GsonBuilder;
|
|||
import com.google.gson.InstanceCreator;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.internal.ConstructorConstructor;
|
||||
import com.google.gson.internal.Excluder;
|
||||
import com.google.gson.internal.JsonReaderInternalAccess;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
|
|
@ -26,6 +26,9 @@ import java.lang.reflect.Modifier;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.json.gson.internal.ConstructorConstructor;
|
||||
import org.jclouds.json.gson.internal.Excluder;
|
||||
import org.jclouds.json.gson.internal.bind.ReflectiveTypeAdapterFactory;
|
||||
import org.jclouds.json.internal.NamingStrategies.AnnotationConstructorNamingStrategy;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
|
@ -40,9 +43,6 @@ import com.google.gson.Gson;
|
|||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.internal.ConstructorConstructor;
|
||||
import com.google.gson.internal.Excluder;
|
||||
import com.google.gson.internal.bind.ReflectiveTypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
|
|
|
@ -16,6 +16,20 @@
|
|||
*/
|
||||
package org.jclouds.json.internal;
|
||||
|
||||
import static com.google.common.base.MoreObjects.toStringHelper;
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.json.gson.internal.JsonReaderInternalAccess;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
|
@ -27,24 +41,11 @@ import com.google.common.collect.Multimap;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.internal.JsonReaderInternalAccess;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.MoreObjects.toStringHelper;
|
||||
|
||||
/**
|
||||
* Eliminates null values when deserializing Collections, Maps, and Multimaps
|
||||
* <p/>
|
||||
|
@ -55,7 +56,7 @@ public class NullFilteringTypeAdapterFactories {
|
|||
}
|
||||
|
||||
static <T> TypeToken<?> resolve(TypeToken<T> ownerType, Type param) {
|
||||
return TypeToken.get(com.google.gson.internal.$Gson$Types.resolve(ownerType.getType(), ownerType.getRawType(),
|
||||
return TypeToken.get(org.jclouds.json.gson.internal.$Gson$Types.resolve(ownerType.getType(), ownerType.getRawType(),
|
||||
param));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,10 @@ import java.io.IOException;
|
|||
import java.io.Writer;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.jclouds.json.gson.internal.bind.TypeAdapters;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.internal.bind.TypeAdapters;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ import javax.inject.Inject;
|
|||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.json.SerializedNames;
|
||||
import org.jclouds.json.gson.internal.ConstructorConstructor;
|
||||
import org.jclouds.json.gson.internal.Excluder;
|
||||
import org.jclouds.json.internal.NamingStrategies.AnnotationConstructorNamingStrategy;
|
||||
import org.jclouds.json.internal.NamingStrategies.AnnotationOrNameFieldNamingStrategy;
|
||||
import org.jclouds.json.internal.NamingStrategies.ExtractNamed;
|
||||
|
@ -48,8 +50,6 @@ import com.google.gson.Gson;
|
|||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.InstanceCreator;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.internal.ConstructorConstructor;
|
||||
import com.google.gson.internal.Excluder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
@Test(testName = "DeserializationConstructorTypeAdapterFactoryTest")
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>jclouds-project</artifactId>
|
||||
<groupId>org.apache.jclouds</groupId>
|
||||
<version>2.2.0-SNAPSHOT</version>
|
||||
<relativePath>../project/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<!--
|
||||
JCLOUDS-1166: This project relocates the 'com.google.gson.internal' package
|
||||
so we can keep using its contents in OSGi environments.
|
||||
This is a temporal solution and we should try to remove the usages of the classes in
|
||||
there and remove this once that is done.
|
||||
-->
|
||||
<artifactId>jclouds-gson</artifactId>
|
||||
<name>jclouds gson copy without internal packages</name>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>shade</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.google.code.gson:gson</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.google.gson.internal</pattern>
|
||||
<shadedPattern>org.jclouds.json.gson.internal</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
|
||||
</transformers>
|
||||
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
1
pom.xml
1
pom.xml
|
@ -31,6 +31,7 @@
|
|||
<modules>
|
||||
<module>project</module>
|
||||
<module>resources</module>
|
||||
<module>gson</module>
|
||||
<module>core</module>
|
||||
<module>common</module>
|
||||
<module>compute</module>
|
||||
|
|
|
@ -254,6 +254,27 @@
|
|||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-gson</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<!--
|
||||
Due to the following issues:
|
||||
https://issues.apache.org/jira/browse/MSHADE-206
|
||||
https://issues.apache.org/jira/browse/MNG-5899
|
||||
The Maven reactor ignores the reduced pom.xml generated by the shade plugin, and all
|
||||
the dependencies that are shaded are included as normal dependencies too, causing
|
||||
duplicate class issues.
|
||||
This exclusion makes sure projects including the shaded version don't get the original
|
||||
gson dependency as well.
|
||||
-->
|
||||
<exclusion>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
|
@ -517,9 +538,11 @@
|
|||
<exclude>**/modernizer_exclusions.txt</exclude>
|
||||
<exclude>**/.factorypath</exclude>
|
||||
<exclude>**/.apt_generated/**</exclude>
|
||||
<exclude>**/.apt_generated_tests/**</exclude>
|
||||
<exclude>**/.checkstyle</exclude>
|
||||
<exclude>nb-configuration.xml</exclude>
|
||||
<exclude>nbactions.xml</exclude>
|
||||
<exclude>dependency-reduced-pom.xml</exclude>
|
||||
|
||||
<!-- Temporary files generated on CloudBees slaves -->
|
||||
<exclude>.repository/**</exclude>
|
||||
|
@ -592,6 +615,32 @@
|
|||
<package>com.jcraft.jsch.agentproxy</package>
|
||||
</packages>
|
||||
</exception>
|
||||
<!--
|
||||
TODO: Remove this when the issues are fixed or we have completely moved away from
|
||||
gson.internal
|
||||
Due to the following issues:
|
||||
https://issues.apache.org/jira/browse/MSHADE-206
|
||||
https://issues.apache.org/jira/browse/MNG-5899
|
||||
The contents of the shaded gson jar are directly included as part of jclouds-core.
|
||||
The classes are exactly the same, so it is safe to exclude them here.
|
||||
-->
|
||||
<exception>
|
||||
<conflictingDependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-gson</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</conflictingDependencies>
|
||||
<packages>
|
||||
<package>org.jclouds.json.gson.internal</package>
|
||||
</packages>
|
||||
</exception>
|
||||
</exceptions>
|
||||
<ignoredResourcePatterns>
|
||||
<!-- For all the jetty packages -->
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
</module>
|
||||
<module name="IllegalImport">
|
||||
<!-- Avoid importing AutoValue shaded packages such as Guava -->
|
||||
<property name="illegalPkgs" value="sun,autovalue,org.testng.internal"/>
|
||||
<property name="illegalPkgs" value="sun,autovalue,org.testng.internal,com.google.gson.internal"/>
|
||||
</module>
|
||||
<module name="WhitespaceAfter">
|
||||
<!-- TYPECAST disabled -->
|
||||
|
|
Loading…
Reference in New Issue