Skip to content

Commit 6a98794

Browse files
committed
added build.gradle template to use in java 11
1 parent 8ae231d commit 6a98794

File tree

8 files changed

+560
-1
lines changed

8 files changed

+560
-1
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,11 @@ public void processOpts() {
182182
//Common files
183183
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
184184
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
185-
writeOptional(outputFolder, new SupportingFile("build.gradle.mustache", "", "build.gradle"));
185+
if (java11Mode) {
186+
writeOptional(outputFolder, new SupportingFile("build.gradle.java11.mustache", "", "build.gradle"));
187+
} else {
188+
writeOptional(outputFolder, new SupportingFile("build.gradle.mustache", "", "build.gradle"));
189+
}
186190
writeOptional(outputFolder, new SupportingFile("build.sbt.mustache", "", "build.sbt"));
187191
writeOptional(outputFolder, new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
188192
writeOptional(outputFolder, new SupportingFile("gradle.properties.mustache", "", "gradle.properties"));
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* defaut
3+
*/
4+
plugins {
5+
id 'java'
6+
id 'maven-publish'
7+
}
8+
9+
repositories {
10+
mavenLocal()
11+
maven {
12+
url = uri('https://repo.maven.apache.org/maven2/')
13+
}
14+
}
15+
16+
ext {
17+
swagger_annotations_version = "1.5.24"
18+
jackson_version = "{{^threetenbp}}2.11.4{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
19+
jersey_version = "1.19.4"
20+
jodatime_version = "2.10.5"
21+
junit_version = "4.13.1"
22+
}
23+
24+
dependencies {
25+
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
26+
implementation "com.sun.jersey:jersey-client:$jersey_version"
27+
implementation "com.sun.jersey.contribs:jersey-multipart:$jersey_version"
28+
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
29+
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
30+
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
31+
implementation "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
32+
{{#joda}}
33+
implementation "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
34+
{{/joda}}
35+
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"}
36+
{{#threetenbp}}
37+
implementation "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version"
38+
{{/threetenbp}}
39+
implementation 'com.sun.xml.ws:jaxws-rt:2.3.3'
40+
testImplementation "junit:junit:$junit_version"
41+
{{#wiremock}}
42+
testImplementation "com.github.tomakehurst:wiremock:2.27.2"
43+
{{/wiremock}}
44+
}
45+
46+
group = '{{groupId}}'
47+
version = '{{artifactVersion}}'
48+
description = '{{artifactDescription}}'
49+
50+
java.sourceCompatibility = 11
51+
java.targetCompatibility = 11
52+
53+
tasks.register('testsJar', Jar) {
54+
archiveClassifier = 'tests'
55+
from(sourceSets.test.output)
56+
}
57+
58+
java {
59+
withSourcesJar()
60+
withJavadocJar()
61+
}
62+
63+
publishing {
64+
publications {
65+
maven(MavenPublication) {
66+
from(components.java)
67+
artifact(testsJar)
68+
}
69+
}
70+
}
71+
72+
tasks.withType(JavaCompile) {
73+
options.encoding = 'UTF-8'
74+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* feign
3+
*/
4+
plugins {
5+
id 'java'
6+
id 'maven-publish'
7+
}
8+
9+
repositories {
10+
mavenLocal()
11+
maven {
12+
url = uri('https://repo.maven.apache.org/maven2/')
13+
}
14+
}
15+
16+
ext {
17+
swagger_annotations_version = "1.5.24"
18+
jackson_version = "2.11.4"
19+
{{#threetenbp}}
20+
threepane_version = "2.6.4"
21+
{{/threetenbp}}
22+
feign_version = "11.6"
23+
feign_form_version = "3.8.0"
24+
junit_version = "4.13.1"
25+
oltu_version = "1.0.1"
26+
}
27+
28+
dependencies {
29+
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
30+
implementation "io.github.openfeign:feign-core:$feign_version"
31+
implementation "io.github.openfeign:feign-jackson:$feign_version"
32+
implementation "io.github.openfeign:feign-slf4j:$feign_version"
33+
implementation "io.github.openfeign.form:feign-form:$feign_form_version"
34+
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
35+
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
36+
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
37+
{{#joda}}
38+
implementation "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
39+
{{/joda}}
40+
{{#java8}}
41+
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
42+
{{/java8}}
43+
{{#threetenbp}}
44+
implementation "com.github.joschi.jackson:jackson-datatype-threetenbp:$threepane_version"
45+
{{/threetenbp}}
46+
implementation "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
47+
implementation "com.brsanthu:migbase64:2.2"
48+
implementation "com.sun.xml.ws:jaxws-rt:2.3.3"
49+
testImplementation "junit:junit:$junit_version"
50+
testImplementation "com.squareup.okhttp3:mockwebserver:3.6.0"
51+
testImplementation "org.assertj:assertj-core:1.7.1"
52+
{{#wiremock}}
53+
testImplementation "com.github.tomakehurst:wiremock:2.27.2"
54+
{{/wiremock}}
55+
}
56+
57+
group = '{{groupId}}'
58+
version = '{{artifactVersion}}'
59+
description = '{{artifactDescription}}'
60+
61+
java.sourceCompatibility = 11
62+
java.targetCompatibility = 11
63+
64+
tasks.register('testsJar', Jar) {
65+
archiveClassifier = 'tests'
66+
from(sourceSets.test.output)
67+
}
68+
69+
java {
70+
withSourcesJar()
71+
withJavadocJar()
72+
}
73+
74+
publishing {
75+
publications {
76+
maven(MavenPublication) {
77+
from(components.java)
78+
artifact(testsJar)
79+
}
80+
}
81+
}
82+
83+
tasks.withType(JavaCompile) {
84+
options.encoding = 'UTF-8'
85+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* jersey2
3+
*/
4+
plugins {
5+
id 'java'
6+
id 'maven-publish'
7+
}
8+
9+
repositories {
10+
mavenLocal()
11+
maven {
12+
url = uri('https://repo.maven.apache.org/maven2/')
13+
}
14+
}
15+
16+
ext {
17+
swagger_annotations_version = "1.5.24"
18+
jackson_version = "2.6.4"
19+
jersey_version = "2.29.1"
20+
junit_version = "4.13.1"
21+
}
22+
23+
dependencies {
24+
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
25+
implementation "org.glassfish.jersey.core:jersey-client:$jersey_version"
26+
implementation "org.glassfish.jersey.media:jersey-media-multipart:$jersey_version"
27+
implementation "org.glassfish.jersey.media:jersey-media-json-jackson:$jersey_version"
28+
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
29+
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
30+
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
31+
{{#withXml}}
32+
implementation "org.glassfish.jersey.media:jersey-media-jaxb:$jersey_version"
33+
{{/withXml}}
34+
{{#joda}}
35+
implementation "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
36+
{{/joda}}
37+
implementation "org.glassfish.jersey.inject:jersey-hk2:$jersey_version"
38+
{{#threetenbp}}
39+
implementation "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version"
40+
{{/threetenbp}}
41+
implementation "com.brsanthu:migbase64:2.2"
42+
testImplementation "junit:junit:$junit_version"
43+
{{#wiremock}}
44+
testImplementation "com.github.tomakehurst:wiremock:2.27.2"
45+
{{/wiremock}}
46+
}
47+
48+
group = '{{groupId}}'
49+
version = '{{artifactVersion}}'
50+
description = '{{artifactDescription}}'
51+
52+
java.sourceCompatibility = 11
53+
java.targetCompatibility = 11
54+
55+
tasks.register('testsJar', Jar) {
56+
archiveClassifier = 'tests'
57+
from(sourceSets.test.output)
58+
}
59+
60+
java {
61+
withSourcesJar()
62+
withJavadocJar()
63+
}
64+
65+
publishing {
66+
publications {
67+
maven(MavenPublication) {
68+
from(components.java)
69+
artifact(testsJar)
70+
}
71+
}
72+
}
73+
74+
tasks.withType(JavaCompile) {
75+
options.encoding = 'UTF-8'
76+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* okhttp
3+
*/
4+
plugins {
5+
id 'java'
6+
id 'maven-publish'
7+
}
8+
9+
repositories {
10+
mavenLocal()
11+
maven {
12+
url = uri('https://repo.maven.apache.org/maven2/')
13+
}
14+
}
15+
16+
dependencies {
17+
implementation 'io.swagger:swagger-annotations:1.5.24'
18+
implementation 'com.squareup.okhttp:okhttp:2.7.5'
19+
implementation 'com.squareup.okhttp:logging-interceptor:2.7.5'
20+
implementation 'com.google.code.gson:gson:2.8.1'
21+
implementation 'io.gsonfire:gson-fire:1.8.0'
22+
{{#joda}}
23+
implementation 'joda-time:joda-time:2.9.9'
24+
{{/joda}}
25+
{{#threetenbp}}
26+
implementation 'org.threeten:threetenbp:1.3.5'
27+
{{/threetenbp}}
28+
implementation 'com.sun.xml.ws:jaxws-rt:2.3.3'
29+
testImplementation 'junit:junit:4.13.1'
30+
{{#wiremock}}
31+
testImplementation "com.github.tomakehurst:wiremock:2.27.2"
32+
{{/wiremock}}
33+
}
34+
35+
group = '{{groupId}}'
36+
version = '{{artifactVersion}}'
37+
description = '{{artifactDescription}}'
38+
39+
java.sourceCompatibility = 11
40+
java.targetCompatibility = 11
41+
42+
tasks.register('testsJar', Jar) {
43+
archiveClassifier = 'tests'
44+
from(sourceSets.test.output)
45+
}
46+
47+
java {
48+
withSourcesJar()
49+
withJavadocJar()
50+
}
51+
52+
publishing {
53+
publications {
54+
maven(MavenPublication) {
55+
from(components.java)
56+
artifact(testsJar)
57+
}
58+
}
59+
}
60+
61+
tasks.withType(JavaCompile) {
62+
options.encoding = 'UTF-8'
63+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* resttemplate
3+
*/
4+
plugins {
5+
id 'java'
6+
id 'maven-publish'
7+
}
8+
9+
repositories {
10+
mavenLocal()
11+
maven {
12+
url = uri('https://repo.maven.apache.org/maven2/')
13+
}
14+
}
15+
16+
ext {
17+
swagger_annotations_version = "1.5.24"
18+
jackson_version = "2.11.4"
19+
spring_web_version = "4.3.9.RELEASE"
20+
jodatime_version = "2.10.5"
21+
junit_version = "4.12"
22+
{{#threetenbp}}
23+
jackson_threeten_version = "2.6.4"
24+
{{/threetenbp}}
25+
}
26+
27+
dependencies {
28+
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
29+
implementation "org.springframework:spring-web:$spring_web_version"
30+
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
31+
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
32+
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
33+
implementation "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
34+
{{#joda}}
35+
implementation "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
36+
implementation "joda-time:joda-time:$jodatime_version"
37+
{{/joda}}
38+
{{#threetenbp}}
39+
implementation "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_threeten_version"
40+
{{/threetenbp}}
41+
{{#withXml}}
42+
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jackson_version"
43+
{{/withXml}}
44+
implementation "com.sun.xml.ws:jaxws-rt:2.3.3"
45+
testImplementation "junit:junit:$junit_version"
46+
{{#wiremock}}
47+
testImplementation "com.github.tomakehurst:wiremock:2.27.2"
48+
{{/wiremock}}
49+
}
50+
51+
group = '{{groupId}}'
52+
version = '{{artifactVersion}}'
53+
description = '{{artifactDescription}}'
54+
55+
java.sourceCompatibility = 11
56+
java.targetCompatibility = 11
57+
58+
tasks.register('testsJar', Jar) {
59+
archiveClassifier = 'tests'
60+
from(sourceSets.test.output)
61+
}
62+
63+
java {
64+
withSourcesJar()
65+
withJavadocJar()
66+
}
67+
68+
publishing {
69+
publications {
70+
maven(MavenPublication) {
71+
from(components.java)
72+
artifact(testsJar)
73+
}
74+
}
75+
}
76+
77+
tasks.withType(JavaCompile) {
78+
options.encoding = 'UTF-8'
79+
}

0 commit comments

Comments
 (0)