Skip to content

Commit a94384c

Browse files
committed
Merge branch 'master' into java-util-model-package
2 parents 6d50ce6 + 583493f commit a94384c

File tree

25 files changed

+852
-61
lines changed

25 files changed

+852
-61
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ CONFIG OPTIONS
276276
apiPackage
277277
package for generated api classes
278278
279+
sortParamsByRequiredFlag
280+
Sort method arguments to place required parameters before optional parameters. Default: true
281+
279282
invokerPackage
280283
root package for generated code
281284
@@ -291,6 +294,12 @@ CONFIG OPTIONS
291294
sourceFolder
292295
source folder for generated code
293296
297+
localVariablePrefix
298+
prefix for generated code members and local variables
299+
300+
serializableModel
301+
boolean - toggle "implements Serializable" for generated models
302+
294303
library
295304
library template (sub-template) to use:
296305
<default> - HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ public void processOpts() {
185185

186186
final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator);
187187
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
188+
supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle"));
189+
supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
190+
supportingFiles.add(new SupportingFile("gradle.properties.mustache", "", "gradle.properties"));
188191
supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java"));
189192
supportingFiles.add(new SupportingFile("StringUtil.mustache", invokerFolder, "StringUtil.java"));
190193

@@ -206,8 +209,6 @@ public void processOpts() {
206209
if ("okhttp-gson".equals(getLibrary())) {
207210
// the "okhttp-gson" library template requires "ApiCallback.mustache" for async call
208211
supportingFiles.add(new SupportingFile("ApiCallback.mustache", invokerFolder, "ApiCallback.java"));
209-
// "build.gradle" is for development with Gradle
210-
supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle"));
211212
// "build.sbt" is for development with SBT
212213
supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt"));
213214
} else if ("retrofit".equals(getLibrary())) {
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
group = '{{groupId}}'
2+
version = '{{artifactVersion}}'
3+
4+
buildscript {
5+
repositories {
6+
jcenter()
7+
}
8+
dependencies {
9+
classpath 'com.android.tools.build:gradle:1.2.2'
10+
classpath 'com.github.dcendents:android-maven-plugin:1.2'
11+
}
12+
}
13+
14+
repositories {
15+
jcenter()
16+
}
17+
18+
19+
if(hasProperty('target') && target == 'android') {
20+
21+
apply plugin: 'com.android.library'
22+
apply plugin: 'com.github.dcendents.android-maven'
23+
24+
android {
25+
compileSdkVersion 22
26+
buildToolsVersion '22.0.0'
27+
defaultConfig {
28+
minSdkVersion 14
29+
targetSdkVersion 22
30+
}
31+
compileOptions {
32+
sourceCompatibility JavaVersion.VERSION_1_7
33+
targetCompatibility JavaVersion.VERSION_1_7
34+
}
35+
36+
// Rename the aar correctly
37+
libraryVariants.all { variant ->
38+
variant.outputs.each { output ->
39+
def outputFile = output.outputFile
40+
if (outputFile != null && outputFile.name.endsWith('.aar')) {
41+
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
42+
output.outputFile = new File(outputFile.parent, fileName)
43+
}
44+
}
45+
}
46+
}
47+
48+
afterEvaluate {
49+
android.libraryVariants.all { variant ->
50+
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
51+
task.description = "Create jar artifact for ${variant.name}"
52+
task.dependsOn variant.javaCompile
53+
task.from variant.javaCompile.destinationDir
54+
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
55+
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
56+
artifacts.add('archives', task);
57+
}
58+
}
59+
60+
task sourcesJar(type: Jar) {
61+
from android.sourceSets.main.java.srcDirs
62+
classifier = 'sources'
63+
}
64+
65+
artifacts {
66+
archives sourcesJar
67+
}
68+
69+
} else {
70+
71+
apply plugin: 'java'
72+
apply plugin: 'maven'
73+
74+
sourceCompatibility = JavaVersion.VERSION_1_7
75+
targetCompatibility = JavaVersion.VERSION_1_7
76+
77+
install {
78+
repositories.mavenInstaller {
79+
pom.artifactId = '{{artifactId}}'
80+
}
81+
}
82+
83+
task execute(type:JavaExec) {
84+
main = System.getProperty('mainClass')
85+
classpath = sourceSets.main.runtimeClasspath
86+
}
87+
}
88+
89+
ext {
90+
swagger_annotations_version = "1.5.0"
91+
jackson_version = "2.4.2"
92+
jersey_version = "1.18"
93+
jodatime_version = "2.3"
94+
junit_version = "4.8.1"
95+
}
96+
97+
dependencies {
98+
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
99+
compile "com.sun.jersey:jersey-client:$jersey_version"
100+
compile "com.sun.jersey.contribs:jersey-multipart:$jersey_version"
101+
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
102+
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
103+
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
104+
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5"
105+
compile "joda-time:joda-time:$jodatime_version"
106+
testCompile "junit:junit:$junit_version"
107+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Uncomment to build for Android
2+
#target = android
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
group = '{{groupId}}'
2+
version = '{{artifactVersion}}'
3+
4+
buildscript {
5+
repositories {
6+
jcenter()
7+
}
8+
dependencies {
9+
classpath 'com.android.tools.build:gradle:1.2.2'
10+
classpath 'com.github.dcendents:android-maven-plugin:1.2'
11+
}
12+
}
13+
14+
repositories {
15+
jcenter()
16+
}
17+
18+
19+
if(hasProperty('target') && target == 'android') {
20+
21+
apply plugin: 'com.android.library'
22+
apply plugin: 'com.github.dcendents.android-maven'
23+
24+
android {
25+
compileSdkVersion 22
26+
buildToolsVersion '22.0.0'
27+
defaultConfig {
28+
minSdkVersion 14
29+
targetSdkVersion 22
30+
}
31+
compileOptions {
32+
sourceCompatibility JavaVersion.VERSION_1_7
33+
targetCompatibility JavaVersion.VERSION_1_7
34+
}
35+
36+
// Rename the aar correctly
37+
libraryVariants.all { variant ->
38+
variant.outputs.each { output ->
39+
def outputFile = output.outputFile
40+
if (outputFile != null && outputFile.name.endsWith('.aar')) {
41+
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
42+
output.outputFile = new File(outputFile.parent, fileName)
43+
}
44+
}
45+
}
46+
}
47+
48+
afterEvaluate {
49+
android.libraryVariants.all { variant ->
50+
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
51+
task.description = "Create jar artifact for ${variant.name}"
52+
task.dependsOn variant.javaCompile
53+
task.from variant.javaCompile.destinationDir
54+
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
55+
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
56+
artifacts.add('archives', task);
57+
}
58+
}
59+
60+
task sourcesJar(type: Jar) {
61+
from android.sourceSets.main.java.srcDirs
62+
classifier = 'sources'
63+
}
64+
65+
artifacts {
66+
archives sourcesJar
67+
}
68+
69+
} else {
70+
71+
apply plugin: 'java'
72+
apply plugin: 'maven'
73+
74+
sourceCompatibility = JavaVersion.VERSION_1_7
75+
targetCompatibility = JavaVersion.VERSION_1_7
76+
77+
install {
78+
repositories.mavenInstaller {
79+
pom.artifactId = '{{artifactId}}'
80+
}
81+
}
82+
83+
task execute(type:JavaExec) {
84+
main = System.getProperty('mainClass')
85+
classpath = sourceSets.main.runtimeClasspath
86+
}
87+
}
88+
89+
ext {
90+
swagger_annotations_version = "1.5.0"
91+
jackson_version = "2.4.2"
92+
jersey_version = "2.6"
93+
jodatime_version = "2.3"
94+
junit_version = "4.8.1"
95+
}
96+
97+
dependencies {
98+
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
99+
compile "org.glassfish.jersey.core:jersey-client:$jersey_version"
100+
compile "org.glassfish.jersey.media:jersey-media-multipart:$jersey_version"
101+
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
102+
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
103+
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
104+
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5"
105+
compile "joda-time:joda-time:$jodatime_version"
106+
testCompile "junit:junit:$junit_version"
107+
}

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

Lines changed: 83 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,89 @@
1-
apply plugin: 'java'
2-
apply plugin: 'maven'
1+
group = '{{groupId}}'
2+
version = '{{artifactVersion}}'
33

4-
sourceCompatibility = JavaVersion.VERSION_1_7
5-
targetCompatibility = JavaVersion.VERSION_1_7
4+
buildscript {
5+
repositories {
6+
jcenter()
7+
}
8+
dependencies {
9+
classpath 'com.android.tools.build:gradle:1.2.2'
10+
classpath 'com.github.dcendents:android-maven-plugin:1.2'
11+
}
12+
}
613

714
repositories {
8-
mavenCentral()
15+
jcenter()
16+
}
17+
18+
19+
if(hasProperty('target') && target == 'android') {
20+
21+
apply plugin: 'com.android.library'
22+
apply plugin: 'com.github.dcendents.android-maven'
23+
24+
android {
25+
compileSdkVersion 22
26+
buildToolsVersion '22.0.0'
27+
defaultConfig {
28+
minSdkVersion 14
29+
targetSdkVersion 22
30+
}
31+
compileOptions {
32+
sourceCompatibility JavaVersion.VERSION_1_7
33+
targetCompatibility JavaVersion.VERSION_1_7
34+
}
35+
36+
// Rename the aar correctly
37+
libraryVariants.all { variant ->
38+
variant.outputs.each { output ->
39+
def outputFile = output.outputFile
40+
if (outputFile != null && outputFile.name.endsWith('.aar')) {
41+
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
42+
output.outputFile = new File(outputFile.parent, fileName)
43+
}
44+
}
45+
}
46+
}
47+
48+
afterEvaluate {
49+
android.libraryVariants.all { variant ->
50+
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
51+
task.description = "Create jar artifact for ${variant.name}"
52+
task.dependsOn variant.javaCompile
53+
task.from variant.javaCompile.destinationDir
54+
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
55+
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
56+
artifacts.add('archives', task);
57+
}
58+
}
59+
60+
task sourcesJar(type: Jar) {
61+
from android.sourceSets.main.java.srcDirs
62+
classifier = 'sources'
63+
}
64+
65+
artifacts {
66+
archives sourcesJar
67+
}
68+
69+
} else {
70+
71+
apply plugin: 'java'
72+
apply plugin: 'maven'
73+
74+
sourceCompatibility = JavaVersion.VERSION_1_7
75+
targetCompatibility = JavaVersion.VERSION_1_7
76+
77+
install {
78+
repositories.mavenInstaller {
79+
pom.artifactId = '{{artifactId}}'
80+
}
81+
}
82+
83+
task execute(type:JavaExec) {
84+
main = System.getProperty('mainClass')
85+
classpath = sourceSets.main.runtimeClasspath
86+
}
987
}
1088

1189
dependencies {
@@ -15,17 +93,3 @@ dependencies {
1593
compile 'com.brsanthu:migbase64:2.2'
1694
testCompile 'junit:junit:4.8.1'
1795
}
18-
19-
group = '{{groupId}}'
20-
version = '{{artifactVersion}}'
21-
22-
install {
23-
repositories.mavenInstaller {
24-
pom.artifactId = '{{artifactId}}'
25-
}
26-
}
27-
28-
task execute(type:JavaExec) {
29-
main = System.getProperty('mainClass')
30-
classpath = sourceSets.main.runtimeClasspath
31-
}

0 commit comments

Comments
 (0)