forked from thebignet/swagger-codegen-gradle-plugin-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
105 lines (90 loc) · 2.94 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath('io.swagger:swagger-codegen:2.2.3')
}
}
plugins {
id 'java'
}
repositories {
mavenCentral()
}
import io.swagger.codegen.config.CodegenConfigurator
import io.swagger.codegen.DefaultGenerator
def swaggerInput = "petstore.json"
def swaggerOutputDir = file('build/swagger')
task generateApi {
inputs.file(swaggerInput)
outputs.dir(swaggerOutputDir)
doLast {
def config = new CodegenConfigurator()
config.setInputSpec(swaggerInput)
config.setOutputDir(swaggerOutputDir.path)
config.setLang('java')
config.setAdditionalProperties([
'invokerPackage': 'io.swagger.petstore.client',
'modelPackage' : 'io.swagger.petstore.client.model',
'apiPackage' : 'io.swagger.petstore.client.api',
'dateLibrary' : 'java8'
])
config.setImportMappings([
'Dog': 'io.swagger.petstore.client.model.Dog'
])
new DefaultGenerator().opts(config.toClientOptInput()).generate()
}
}
clean.doFirst {
delete(swaggerOutputDir)
}
configurations {
swagger
}
sourceSets {
swagger {
compileClasspath = configurations.swaggerCompile
java {
srcDir file("${project.buildDir.path}/swagger/src/main/java")
}
}
main {
compileClasspath += swagger.output
runtimeClasspath += swagger.output
}
test {
compileClasspath += swagger.output
runtimeClasspath += swagger.output
}
}
compileSwaggerJava.dependsOn generateApi
classes.dependsOn swaggerClasses
compileJava.dependsOn compileSwaggerJava
ext {
spring_boot_version = '1.5.6.RELEASE'
jackson_version = '2.4.2'
jersey_version = '1.18'
jodatime_version = '2.3'
junit_version = '4.8.1'
}
dependencies {
swaggerCompile "org.springframework.boot:spring-boot-starter-web:$spring_boot_version"
swaggerCompile 'io.swagger:swagger-annotations:1.5.16'
swaggerCompile 'com.squareup.okhttp:okhttp:2.7.5'
swaggerCompile 'com.squareup.okhttp:logging-interceptor:2.7.5'
swaggerCompile 'com.google.code.gson:gson:2.8.1'
compile sourceSets.swagger.output
compile "com.sun.jersey:jersey-client:$jersey_version"
compile "com.sun.jersey.contribs:jersey-multipart:$jersey_version"
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5"
compile "joda-time:joda-time:$jodatime_version"
compile 'io.swagger:swagger-codegen:2.2.3'
testCompile "junit:junit:$junit_version"
runtime 'com.squareup.okhttp:okhttp:2.7.5'
runtime 'com.squareup.okhttp:logging-interceptor:2.7.5'
runtime 'com.google.code.gson:gson:2.8.1'
}