Skip to content

Commit e98928a

Browse files
authored
Merge pull request #3186 from ant3/JSR310-Clients
[Java] Add support for JSR310 in Jersey Clients (v3)
2 parents 82ee6bb + 8b60a1e commit e98928a

File tree

105 files changed

+8115
-55
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+8115
-55
lines changed

bin/all-petstore.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ cd $APP_DIR
3030
./bin/java-petstore-okhttp-gson.sh
3131
./bin/java-petstore-retrofit.sh
3232
./bin/java-petstore-retrofit2.sh
33+
./bin/java8-petstore-jersey2.sh
3334
./bin/jaxrs-petstore-server.sh
3435
./bin/nodejs-petstore-server.sh
3536
./bin/objc-petstore.sh

bin/java-petstore-all.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
./bin/java-petstore-retrofit.sh
99
./bin/java-petstore-retrofit2.sh
1010
./bin/java-petstore-retrofit2rx.sh
11+
./bin/java8-petstore-jersey2.sh

bin/java8-petstore-jersey2.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"library": "jersey2",
3+
"artifactId": "swagger-petstore-jersey2",
4+
"dateLibrary": "java8"
5+
}

bin/java8-petstore-jersey2.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
5+
while [ -h "$SCRIPT" ] ; do
6+
ls=`ls -ld "$SCRIPT"`
7+
link=`expr "$ls" : '.*-> \(.*\)$'`
8+
if expr "$link" : '/.*' > /dev/null; then
9+
SCRIPT="$link"
10+
else
11+
SCRIPT=`dirname "$SCRIPT"`/"$link"
12+
fi
13+
done
14+
15+
if [ ! -d "${APP_DIR}" ]; then
16+
APP_DIR=`dirname "$SCRIPT"`/..
17+
APP_DIR=`cd "${APP_DIR}"; pwd`
18+
fi
19+
20+
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
21+
22+
if [ ! -f "$executable" ]
23+
then
24+
mvn clean package
25+
fi
26+
27+
# if you've executed sbt assembly previously it will use that instead.
28+
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29+
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java8-petstore-jersey2.json -o samples/client/petstore/java/jersey2-java8 -DhideGenerationTimestamp=true"
30+
31+
echo "Removing files and folders under samples/client/petstore/java/jersey2-java8/src/main"
32+
rm -rf samples/client/petstore/java/jersey2-java8/src/main
33+
find samples/client/petstore/java/jersey2-java8 -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
34+
java $JAVA_OPTS -jar $executable $ags

modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public class ApiClient {
7171
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
7272
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
7373
{{#java8}}
74-
objectMapper.registerModule(new JSR310Module());
74+
objectMapper.registerModule(new JavaTimeModule());
7575
{{/java8}}
7676
{{^java8}}
7777
objectMapper.registerModule(new JodaModule());

modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ if(hasProperty('target') && target == 'android') {
3232
targetSdkVersion 23
3333
}
3434
compileOptions {
35+
{{#java8}}
36+
sourceCompatibility JavaVersion.VERSION_1_8
37+
targetCompatibility JavaVersion.VERSION_1_8
38+
{{/java8}}
39+
{{^java8}}
3540
sourceCompatibility JavaVersion.VERSION_1_7
3641
targetCompatibility JavaVersion.VERSION_1_7
42+
{{/java8}}
3743
}
3844

3945
// Rename the aar correctly
@@ -77,9 +83,15 @@ if(hasProperty('target') && target == 'android') {
7783
7884
apply plugin: 'java'
7985
apply plugin: 'maven'
80-
86+
87+
{{#java8}}
88+
sourceCompatibility = JavaVersion.VERSION_1_8
89+
targetCompatibility = JavaVersion.VERSION_1_8
90+
{{/java8}}
91+
{{^java8}}
8192
sourceCompatibility = JavaVersion.VERSION_1_7
8293
targetCompatibility = JavaVersion.VERSION_1_7
94+
{{/java8}}
8395

8496
install {
8597
repositories.mavenInstaller {
@@ -95,9 +107,9 @@ if(hasProperty('target') && target == 'android') {
95107

96108
ext {
97109
swagger_annotations_version = "1.5.8"
98-
jackson_version = "2.7.0"
110+
jackson_version = "2.7.5"
99111
jersey_version = "1.19.1"
100-
jodatime_version = "2.9.3"
112+
jodatime_version = "2.9.4"
101113
junit_version = "4.12"
102114
}
103115

@@ -109,8 +121,13 @@ dependencies {
109121
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
110122
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
111123
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
112-
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5"
124+
{{#java8}}
125+
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
126+
{{/java8}}
127+
{{^java8}}
128+
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
113129
compile "joda-time:joda-time:$jodatime_version"
130+
{{/java8}}
114131
compile "com.brsanthu:migbase64:2.2"
115132
testCompile "junit:junit:$junit_version"
116133
}

modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/JSON.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class JSON implements ContextResolver<ObjectMapper> {
2525
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
2626
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
2727
{{#java8}}
28-
mapper.registerModule(new JSR310Module());
28+
mapper.registerModule(new JavaTimeModule());
2929
{{/java8}}
3030
{{^java8}}
3131
mapper.registerModule(new JodaModule());

modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ if(hasProperty('target') && target == 'android') {
106106

107107
ext {
108108
swagger_annotations_version = "1.5.8"
109-
jackson_version = "2.7.0"
109+
jackson_version = "2.7.5"
110110
jersey_version = "2.22.2"
111111
{{^java8}}
112-
jodatime_version = "2.9.3"
112+
jodatime_version = "2.9.4"
113113
{{/java8}}
114114
junit_version = "4.12"
115115
}
@@ -118,15 +118,15 @@ dependencies {
118118
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
119119
compile "org.glassfish.jersey.core:jersey-client:$jersey_version"
120120
compile "org.glassfish.jersey.media:jersey-media-multipart:$jersey_version"
121-
compile "org.glassfish.jersey.media:jersey-media-json-jackson:2.22.1"
121+
compile "org.glassfish.jersey.media:jersey-media-json-jackson:$jersey_version"
122122
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
123123
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
124124
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
125125
{{#java8}}
126126
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
127127
{{/java8}}
128128
{{^java8}}
129-
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5"
129+
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
130130
compile "joda-time:joda-time:$jodatime_version"
131131
{{/java8}}
132132
compile "com.brsanthu:migbase64:2.2"

modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.sbt.mustache

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ lazy val root = (project in file(".")).
1212
"io.swagger" % "swagger-annotations" % "1.5.8",
1313
"org.glassfish.jersey.core" % "jersey-client" % "2.22.2",
1414
"org.glassfish.jersey.media" % "jersey-media-multipart" % "2.22.2",
15-
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % "2.22.1",
16-
"com.fasterxml.jackson.core" % "jackson-core" % "2.7.0",
17-
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.7.0",
18-
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.0",
15+
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % "2.22.2",
16+
"com.fasterxml.jackson.core" % "jackson-core" % "2.7.5",
17+
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.7.5",
18+
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.5",
1919
{{#java8}}
20-
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.7.0",
20+
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.7.5",
2121
{{/java8}}
2222
{{^java8}}
23-
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.1.5",
24-
"joda-time" % "joda-time" % "2.9.3",
23+
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.7.5",
24+
"joda-time" % "joda-time" % "2.9.4",
2525
{{/java8}}
2626
"com.brsanthu" % "migbase64" % "2.2",
2727
"junit" % "junit" % "4.12" % "test",

modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<plugin>
5353
<groupId>org.apache.maven.plugins</groupId>
5454
<artifactId>maven-jar-plugin</artifactId>
55-
<version>2.2</version>
55+
<version>2.6</version>
5656
<executions>
5757
<execution>
5858
<goals>
@@ -98,7 +98,7 @@
9898
<plugin>
9999
<groupId>org.apache.maven.plugins</groupId>
100100
<artifactId>maven-compiler-plugin</artifactId>
101-
<version>2.3.2</version>
101+
<version>2.5.1</version>
102102
<configuration>
103103
{{#java8}}
104104
<source>1.8</source>
@@ -133,7 +133,7 @@
133133
<dependency>
134134
<groupId>org.glassfish.jersey.media</groupId>
135135
<artifactId>jersey-media-json-jackson</artifactId>
136-
<version>2.22.1</version>
136+
<version>${jersey-version}</version>
137137
</dependency>
138138

139139
<!-- JSON processing: jackson -->
@@ -163,7 +163,7 @@
163163
<dependency>
164164
<groupId>com.fasterxml.jackson.datatype</groupId>
165165
<artifactId>jackson-datatype-joda</artifactId>
166-
<version>2.1.5</version>
166+
<version>${jackson-version}</version>
167167
</dependency>
168168
<dependency>
169169
<groupId>joda-time</groupId>
@@ -190,9 +190,9 @@
190190
<properties>
191191
<swagger-core-version>1.5.8</swagger-core-version>
192192
<jersey-version>2.22.2</jersey-version>
193-
<jackson-version>2.7.0</jackson-version>
193+
<jackson-version>2.7.5</jackson-version>
194194
{{^java8}}
195-
<jodatime-version>2.9.3</jodatime-version>
195+
<jodatime-version>2.9.4</jodatime-version>
196196
{{/java8}}
197197
<maven-plugin-version>1.0.0</maven-plugin-version>
198198
<junit-version>4.12</junit-version>

0 commit comments

Comments
 (0)