Skip to content

Commit 5a0a8f6

Browse files
jminiwing328
authored andcommitted
Java6 support: fix pom and gradle files, avoid diamond notation (#560)
1 parent df81534 commit 5a0a8f6

31 files changed

Lines changed: 256 additions & 31 deletions

File tree

modules/openapi-generator/src/main/resources/Java/README.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
## Requirements
1919

2020
Building the API client library requires:
21-
1. Java {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}+
21+
1. Java {{#supportJava6}}1.6{{/supportJava6}}{{^supportJava6}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/supportJava6}}+
2222
2. Maven/Gradle
2323

2424
## Installation

modules/openapi-generator/src/main/resources/Java/build.gradle.mustache

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ if(hasProperty('target') && target == 'android') {
3131
targetSdkVersion 25
3232
}
3333
compileOptions {
34+
{{#supportJava6}}
35+
sourceCompatibility JavaVersion.VERSION_1_6
36+
targetCompatibility JavaVersion.VERSION_1_6
37+
{{/supportJava6}}
38+
{{^supportJava6}}
3439
{{#java8}}
3540
sourceCompatibility JavaVersion.VERSION_1_8
3641
targetCompatibility JavaVersion.VERSION_1_8
@@ -39,6 +44,7 @@ if(hasProperty('target') && target == 'android') {
3944
sourceCompatibility JavaVersion.VERSION_1_7
4045
targetCompatibility JavaVersion.VERSION_1_7
4146
{{/java8}}
47+
{{/supportJava6}}
4248
}
4349

4450
// Rename the aar correctly
@@ -83,6 +89,11 @@ if(hasProperty('target') && target == 'android') {
8389
apply plugin: 'java'
8490
apply plugin: 'maven'
8591
92+
{{#supportJava6}}
93+
sourceCompatibility = JavaVersion.VERSION_1_6
94+
targetCompatibility = JavaVersion.VERSION_1_6
95+
{{/supportJava6}}
96+
{{^supportJava6}}
8697
{{#java8}}
8798
sourceCompatibility = JavaVersion.VERSION_1_8
8899
targetCompatibility = JavaVersion.VERSION_1_8
@@ -91,6 +102,7 @@ if(hasProperty('target') && target == 'android') {
91102
sourceCompatibility = JavaVersion.VERSION_1_7
92103
targetCompatibility = JavaVersion.VERSION_1_7
93104
{{/java8}}
105+
{{/supportJava6}}
94106

95107
install {
96108
repositories.mavenInstaller {

modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ if(hasProperty('target') && target == 'android') {
3232
targetSdkVersion 25
3333
}
3434
compileOptions {
35+
{{#supportJava6}}
36+
sourceCompatibility JavaVersion.VERSION_1_6
37+
targetCompatibility JavaVersion.VERSION_1_6
38+
{{/supportJava6}}
39+
{{^supportJava6}}
3540
{{#java8}}
3641
sourceCompatibility JavaVersion.VERSION_1_8
3742
targetCompatibility JavaVersion.VERSION_1_8
@@ -40,6 +45,7 @@ if(hasProperty('target') && target == 'android') {
4045
sourceCompatibility JavaVersion.VERSION_1_7
4146
targetCompatibility JavaVersion.VERSION_1_7
4247
{{/java8}}
48+
{{/supportJava6}}
4349
}
4450

4551
// Rename the aar correctly
@@ -84,8 +90,20 @@ if(hasProperty('target') && target == 'android') {
8490
apply plugin: 'java'
8591
apply plugin: 'maven'
8692
87-
sourceCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
88-
targetCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
93+
{{#supportJava6}}
94+
sourceCompatibility = JavaVersion.VERSION_1_6
95+
targetCompatibility = JavaVersion.VERSION_1_6
96+
{{/supportJava6}}
97+
{{^supportJava6}}
98+
{{#java8}}
99+
sourceCompatibility = JavaVersion.VERSION_1_8
100+
targetCompatibility = JavaVersion.VERSION_1_8
101+
{{/java8}}
102+
{{^java8}}
103+
sourceCompatibility = JavaVersion.VERSION_1_7
104+
targetCompatibility = JavaVersion.VERSION_1_7
105+
{{/java8}}
106+
{{/supportJava6}}
89107

90108
install {
91109
repositories.mavenInstaller {

modules/openapi-generator/src/main/resources/Java/libraries/feign/pom.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@
291291
</dependencies>
292292
<properties>
293293
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
294-
<java.version>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</java.version>
294+
<java.version>{{#supportJava6}}1.6{{/supportJava6}}{{^supportJava6}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/supportJava6}}</java.version>
295295
<maven.compiler.source>${java.version}</maven.compiler.source>
296296
<maven.compiler.target>${java.version}</maven.compiler.target>
297297
<swagger-core-version>1.5.18</swagger-core-version>

modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ if(hasProperty('target') && target == 'android') {
3232
targetSdkVersion 22
3333
}
3434
compileOptions {
35+
{{#supportJava6}}
36+
sourceCompatibility JavaVersion.VERSION_1_6
37+
targetCompatibility JavaVersion.VERSION_1_6
38+
{{/supportJava6}}
39+
{{^supportJava6}}
3540
{{#java8}}
3641
sourceCompatibility JavaVersion.VERSION_1_8
3742
targetCompatibility JavaVersion.VERSION_1_8
@@ -40,6 +45,7 @@ if(hasProperty('target') && target == 'android') {
4045
sourceCompatibility JavaVersion.VERSION_1_7
4146
targetCompatibility JavaVersion.VERSION_1_7
4247
{{/java8}}
48+
{{/supportJava6}}
4349
}
4450

4551
// Rename the aar correctly
@@ -84,6 +90,11 @@ if(hasProperty('target') && target == 'android') {
8490
apply plugin: 'java'
8591
apply plugin: 'maven'
8692
93+
{{#supportJava6}}
94+
sourceCompatibility = JavaVersion.VERSION_1_6
95+
targetCompatibility = JavaVersion.VERSION_1_6
96+
{{/supportJava6}}
97+
{{^supportJava6}}
8798
{{#java8}}
8899
sourceCompatibility = JavaVersion.VERSION_1_8
89100
targetCompatibility = JavaVersion.VERSION_1_8
@@ -92,6 +103,7 @@ if(hasProperty('target') && target == 'android') {
92103
sourceCompatibility = JavaVersion.VERSION_1_7
93104
targetCompatibility = JavaVersion.VERSION_1_7
94105
{{/java8}}
106+
{{/supportJava6}}
95107

96108
install {
97109
repositories.mavenInstaller {

modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@
139139
<artifactId>maven-compiler-plugin</artifactId>
140140
<version>3.6.1</version>
141141
<configuration>
142+
{{#supportJava6}}
143+
<source>1.6</source>
144+
<target>1.6</target>
145+
{{/supportJava6}}
146+
{{^supportJava6}}
142147
{{#java8}}
143148
<source>1.8</source>
144149
<target>1.8</target>
@@ -147,6 +152,7 @@
147152
<source>1.7</source>
148153
<target>1.7</target>
149154
{{/java8}}
155+
{{/supportJava6}}
150156
</configuration>
151157
</plugin>
152158
<plugin>

modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,12 +709,12 @@ public class ApiClient {
709709
Map<String, List<String>> responseHeaders = buildResponseHeaders(response);
710710

711711
if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) {
712-
return new ApiResponse<>(statusCode, responseHeaders);
712+
return new ApiResponse<{{#supportJava6}}T{{/supportJava6}}>(statusCode, responseHeaders);
713713
} else if (response.getStatusInfo().getFamily() == Status.Family.SUCCESSFUL) {
714714
if (returnType == null)
715-
return new ApiResponse<>(statusCode, responseHeaders);
715+
return new ApiResponse<{{#supportJava6}}T{{/supportJava6}}>(statusCode, responseHeaders);
716716
else
717-
return new ApiResponse<>(statusCode, responseHeaders, deserialize(response, returnType));
717+
return new ApiResponse<{{#supportJava6}}T{{/supportJava6}}>(statusCode, responseHeaders, deserialize(response, returnType));
718718
} else {
719719
String message = "error";
720720
String respBody = null;

modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ if(hasProperty('target') && target == 'android') {
3232
targetSdkVersion 25
3333
}
3434
compileOptions {
35+
{{#supportJava6}}
36+
sourceCompatibility JavaVersion.VERSION_1_6
37+
targetCompatibility JavaVersion.VERSION_1_6
38+
{{/supportJava6}}
39+
{{^supportJava6}}
3540
{{#java8}}
3641
sourceCompatibility JavaVersion.VERSION_1_8
3742
targetCompatibility JavaVersion.VERSION_1_8
@@ -40,6 +45,7 @@ if(hasProperty('target') && target == 'android') {
4045
sourceCompatibility JavaVersion.VERSION_1_7
4146
targetCompatibility JavaVersion.VERSION_1_7
4247
{{/java8}}
48+
{{/supportJava6}}
4349
}
4450

4551
// Rename the aar correctly
@@ -83,6 +89,11 @@ if(hasProperty('target') && target == 'android') {
8389
8490
apply plugin: 'java'
8591
apply plugin: 'maven'
92+
{{#supportJava6}}
93+
sourceCompatibility = JavaVersion.VERSION_1_6
94+
targetCompatibility = JavaVersion.VERSION_1_6
95+
{{/supportJava6}}
96+
{{^supportJava6}}
8697
{{#java8}}
8798
sourceCompatibility = JavaVersion.VERSION_1_8
8899
targetCompatibility = JavaVersion.VERSION_1_8
@@ -91,6 +102,7 @@ if(hasProperty('target') && target == 'android') {
91102
sourceCompatibility = JavaVersion.VERSION_1_7
92103
targetCompatibility = JavaVersion.VERSION_1_7
93104
{{/java8}}
105+
{{/supportJava6}}
94106

95107
install {
96108
repositories.mavenInstaller {

modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@
139139
<artifactId>maven-compiler-plugin</artifactId>
140140
<version>3.6.1</version>
141141
<configuration>
142+
{{#supportJava6}}
143+
<source>1.6</source>
144+
<target>1.6</target>
145+
{{/supportJava6}}
146+
{{^supportJava6}}
142147
{{#java8}}
143148
<source>1.8</source>
144149
<target>1.8</target>
@@ -147,6 +152,7 @@
147152
<source>1.7</source>
148153
<target>1.7</target>
149154
{{/java8}}
155+
{{/supportJava6}}
150156
</configuration>
151157
</plugin>
152158
<plugin>

modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ if(hasProperty('target') && target == 'android') {
3232
targetSdkVersion 25
3333
}
3434
compileOptions {
35+
{{#supportJava6}}
36+
sourceCompatibility JavaVersion.VERSION_1_6
37+
targetCompatibility JavaVersion.VERSION_1_6
38+
{{/supportJava6}}
39+
{{^supportJava6}}
3540
{{#java8}}
3641
sourceCompatibility JavaVersion.VERSION_1_8
3742
targetCompatibility JavaVersion.VERSION_1_8
@@ -40,6 +45,7 @@ if(hasProperty('target') && target == 'android') {
4045
sourceCompatibility JavaVersion.VERSION_1_7
4146
targetCompatibility JavaVersion.VERSION_1_7
4247
{{/java8}}
48+
{{/supportJava6}}
4349
}
4450

4551
// Rename the aar correctly
@@ -84,8 +90,20 @@ if(hasProperty('target') && target == 'android') {
8490
apply plugin: 'java'
8591
apply plugin: 'maven'
8692
87-
sourceCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
88-
targetCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}}
93+
{{#supportJava6}}
94+
sourceCompatibility = JavaVersion.VERSION_1_6
95+
targetCompatibility = JavaVersion.VERSION_1_6
96+
{{/supportJava6}}
97+
{{^supportJava6}}
98+
{{#java8}}
99+
sourceCompatibility = JavaVersion.VERSION_1_8
100+
targetCompatibility = JavaVersion.VERSION_1_8
101+
{{/java8}}
102+
{{^java8}}
103+
sourceCompatibility = JavaVersion.VERSION_1_7
104+
targetCompatibility = JavaVersion.VERSION_1_7
105+
{{/java8}}
106+
{{/supportJava6}}
89107

90108
install {
91109
repositories.mavenInstaller {

0 commit comments

Comments
 (0)