Skip to content

Commit 9e72aa5

Browse files
committed
Remoção de dependencias externas. Uso da lib Gson para conversão da resposta. Utilização do ProGuard para optimizar a lib
1 parent 35c1f63 commit 9e72aa5

File tree

4 files changed

+122
-68
lines changed

4 files changed

+122
-68
lines changed

pom.xml

Lines changed: 64 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,7 @@
99
<groupId>com.github.nidorx</groupId>
1010
<artifactId>http-request</artifactId>
1111
<version>1.0.0</version>
12-
<build>
13-
<plugins>
14-
<plugin>
15-
<groupId>org.apache.maven.plugins</groupId>
16-
<artifactId>maven-compiler-plugin</artifactId>
17-
<configuration>
18-
<source>8</source>
19-
<target>8</target>
20-
</configuration>
21-
</plugin>
22-
</plugins>
23-
</build>
12+
2413
<packaging>jar</packaging>
2514

2615
<name>HttpRequest</name>
@@ -31,6 +20,7 @@
3120
<maven>3.5.2</maven>
3221
</prerequisites>
3322

23+
3424
<contributors>
3525
<contributor>
3626
<name>Alex Rodin</name>
@@ -49,17 +39,7 @@
4939
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
5040
<java.version>1.8</java.version>
5141

52-
<sonar-maven-plugin.version>4.5.7</sonar-maven-plugin.version>
53-
<maven-checkstyle-plugin.version>2.12.1</maven-checkstyle-plugin.version>
54-
<maven-site-plugin.version>3.3</maven-site-plugin.version>
55-
<maven-javadoc-plugin.version>2.9.1</maven-javadoc-plugin.version>
56-
<maven-source-plugin.version>2.1.2</maven-source-plugin.version>
57-
58-
<start-class>torneio.Aplicacao</start-class>
59-
<arquitetura-spring.version>0.0.4-SNAPSHOT</arquitetura-spring.version>
60-
<sonar.projectKey>csgo-torneio-server</sonar.projectKey>
61-
<sonar.host.url>http://3.95.91.2:9000</sonar.host.url>
62-
<sonar.login>8e99796f608e91ad5092493d3203c6b22ffd4350</sonar.login>
42+
<jackson.version>2.9.8</jackson.version>
6343
</properties>
6444

6545
<repositories>
@@ -90,4 +70,65 @@
9070
</releases>
9171
</pluginRepository>
9272
</pluginRepositories>
73+
74+
<dependencies>
75+
<!--<dependency>-->
76+
<!--<groupId>com.fasterxml.jackson.core</groupId>-->
77+
<!--<artifactId>jackson-databind</artifactId>-->
78+
<!--<version>${jackson.version}</version>-->
79+
<!--</dependency>-->
80+
<dependency>
81+
<groupId>com.google.code.gson</groupId>
82+
<artifactId>gson</artifactId>
83+
<version>2.8.5</version>
84+
</dependency>
85+
</dependencies>
86+
87+
<build>
88+
<plugins>
89+
<plugin>
90+
<groupId>org.apache.maven.plugins</groupId>
91+
<artifactId>maven-compiler-plugin</artifactId>
92+
<version>3.8.0</version>
93+
<configuration>
94+
<source>8</source>
95+
<target>8</target>
96+
</configuration>
97+
</plugin>
98+
<plugin>
99+
<groupId>org.apache.maven.plugins</groupId>
100+
<artifactId>maven-shade-plugin</artifactId>
101+
<version>3.2.1</version>
102+
<executions>
103+
<execution>
104+
<phase>package</phase>
105+
<goals>
106+
<goal>shade</goal>
107+
</goals>
108+
</execution>
109+
</executions>
110+
<configuration>
111+
<minimizeJar>true</minimizeJar>
112+
</configuration>
113+
</plugin>
114+
<plugin>
115+
<groupId>com.github.wvengen</groupId>
116+
<artifactId>proguard-maven-plugin</artifactId>
117+
<version>2.1.0</version>
118+
<executions>
119+
<execution>
120+
<phase>package</phase>
121+
<goals>
122+
<goal>proguard</goal>
123+
</goals>
124+
125+
<configuration>
126+
<injar>${project.build.finalName}.jar</injar>
127+
<proguardVersion>5.3</proguardVersion>
128+
</configuration>
129+
</execution>
130+
</executions>
131+
</plugin>
132+
</plugins>
133+
</build>
93134
</project>

proguard.conf

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#https://www.guardsquare.com/en/proguard/manual/introduction
2+
3+
# Java runtime
4+
-libraryjars <java.home>/lib/rt.jar
5+
-verbose
6+
#-dontnote
7+
8+
-optimizations !code/allocation/variable
9+
#-keepparameternames
10+
-renamesourcefileattribute SourceFile
11+
-repackageclasses 'com.github.nidorx.gson'
12+
-allowaccessmodification
13+
14+
# Annotations and signatures
15+
-keepattributes *Annotation*,Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,EnclosingMethod
16+
17+
18+
# Preserva todas as classes publicas, seus métodos public e protected
19+
-keep public class com.github.nidorx.http.** {
20+
public protected *;
21+
}
22+
23+
# Preserva os nomes de métods de todas as .class
24+
-keepclassmembernames class * {
25+
java.lang.Class class$(java.lang.String);
26+
java.lang.Class class$(java.lang.String, boolean);
27+
}
28+
29+
# Preserva todos os nomes de métodos nativos e o nome de suas classes
30+
-keepclasseswithmembernames class * {
31+
native <methods>;
32+
}
33+
34+
# Preserve the special static methods that are required in all enumeration classes.
35+
-keepclassmembers class * extends java.lang.Enum {
36+
public static **[] values();
37+
public static ** valueOf(java.lang.String);
38+
}
39+
40+
# Explicitly preserve all serialization members. The Serializable interface
41+
# is only a marker interface, so it wouldn't save them.
42+
# You can comment this out if your library doesn't use serialization.
43+
# If your code contains serializable classes that have to be backward
44+
# compatible, please refer to the manual.
45+
46+
-keepclassmembers class * implements java.io.Serializable {
47+
java.lang.Object readResolve();
48+
java.lang.Object writeReplace();
49+
static final long serialVersionUID;
50+
private void readObject(java.io.ObjectInputStream);
51+
private void writeObject(java.io.ObjectOutputStream);
52+
static final java.io.ObjectStreamField[] serialPersistentFields;
53+
}

src/main/java/com/github/nidorx/http/HttpResponse.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.nidorx.http;
22

3-
import com.github.nidorx.http.util.ObjectMapper;
3+
4+
import com.google.gson.Gson;
45

56
import java.net.CookieManager;
67
import java.util.HashMap;
@@ -12,7 +13,7 @@
1213
*/
1314
public class HttpResponse {
1415

15-
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
16+
private static final Gson OBJECT_MAPPER = new Gson();
1617

1718
public int statusCode;
1819

@@ -26,14 +27,14 @@ public Map<String, Object> asJson() throws Exception {
2627
if (content == null || content.isEmpty()) {
2728
return null;
2829
}
29-
return OBJECT_MAPPER.readValue(content, HashMap.class);
30+
return OBJECT_MAPPER.fromJson(content, HashMap.class);
3031
}
3132

3233
public <T> T asJson(Class<T> type) throws Exception {
3334
if (content == null || content.isEmpty()) {
3435
return null;
3536
}
36-
return OBJECT_MAPPER.readValue(content, type);
37+
return OBJECT_MAPPER.fromJson(content, type);
3738
}
3839

3940
public boolean isSuccess() {

src/main/java/com/github/nidorx/http/util/ObjectMapper.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)