-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathbuild.gradle
204 lines (165 loc) · 8.67 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
plugins {
id "org.openapi.generator" version "6.2.1"
id "java-library"
}
def specFile = "$projectDir/src/main/openapi/config.yaml"
// Deprecated -- can be removed once airbyte-server is converted to use the per-domain endpoints generated by generateApiServer
task generateApiServerLegacy(type: GenerateTask) {
def serverOutputDir = "$buildDir/generated/api/server"
inputs.file specFile
outputs.dir serverOutputDir
generatorName = "jaxrs-spec"
inputSpec = specFile
outputDir = serverOutputDir
apiPackage = "io.airbyte.api.generated"
invokerPackage = "io.airbyte.api.invoker.generated"
modelPackage = "io.airbyte.api.model.generated"
schemaMappings = [
'OAuthConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
'SourceDefinitionSpecification' : 'com.fasterxml.jackson.databind.JsonNode',
'SourceConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
'DestinationDefinitionSpecification': 'com.fasterxml.jackson.databind.JsonNode',
'DestinationConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
'StreamJsonSchema' : 'com.fasterxml.jackson.databind.JsonNode',
'StateBlob' : 'com.fasterxml.jackson.databind.JsonNode',
'FieldSchema' : 'com.fasterxml.jackson.databind.JsonNode',
]
generateApiDocumentation = false
configOptions = [
dateLibrary : "java8",
generatePom : "false",
interfaceOnly: "true",
/*
JAX-RS generator does not respect nullable properties defined in the OpenApi Spec.
It means that if a field is not nullable but not set it is still returning a null value for this field in the serialized json.
The below Jackson annotation is made to only keep non null values in serialized json.
We are not yet using nullable=true properties in our OpenApi so this is a valid workaround at the moment to circumvent the default JAX-RS behavior described above.
Feel free to read the conversation on https://github.com/airbytehq/airbyte/pull/13370 for more details.
*/
additionalModelTypeAnnotations: "\n@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)",
]
}
task generateApiServer(type: GenerateTask) {
def serverOutputDir = "$buildDir/generated/api/server"
inputs.file specFile
outputs.dir serverOutputDir
generatorName = "jaxrs-spec"
inputSpec = specFile
outputDir = serverOutputDir
apiPackage = "io.airbyte.api.generated"
invokerPackage = "io.airbyte.api.invoker.generated"
modelPackage = "io.airbyte.api.model.generated"
schemaMappings = [
'OAuthConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
'SourceDefinitionSpecification' : 'com.fasterxml.jackson.databind.JsonNode',
'SourceConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
'DestinationDefinitionSpecification': 'com.fasterxml.jackson.databind.JsonNode',
'DestinationConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
'StreamJsonSchema' : 'com.fasterxml.jackson.databind.JsonNode',
'StateBlob' : 'com.fasterxml.jackson.databind.JsonNode',
'FieldSchema' : 'com.fasterxml.jackson.databind.JsonNode',
]
generateApiDocumentation = false
configOptions = [
dateLibrary : "java8",
generatePom : "false",
interfaceOnly: "true",
/*
JAX-RS generator does not respect nullable properties defined in the OpenApi Spec.
It means that if a field is not nullable but not set it is still returning a null value for this field in the serialized json.
The below Jackson annotation is made to only keep non null values in serialized json.
We are not yet using nullable=true properties in our OpenApi so this is a valid workaround at the moment to circumvent the default JAX-RS behavior described above.
Feel free to read the conversation on https://github.com/airbytehq/airbyte/pull/13370 for more details.
*/
additionalModelTypeAnnotations: "\n@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)",
// Generate separate classes for each endpoint "domain"
useTags: "true"
]
}
compileJava.dependsOn tasks.generateApiServerLegacy, tasks.generateApiServer
task generateApiClient(type: GenerateTask) {
def clientOutputDir = "$buildDir/generated/api/client"
inputs.file specFile
outputs.dir clientOutputDir
generatorName = "java"
inputSpec = specFile
outputDir = clientOutputDir
apiPackage = "io.airbyte.api.client.generated"
invokerPackage = "io.airbyte.api.client.invoker.generated"
modelPackage = "io.airbyte.api.client.model.generated"
schemaMappings = [
'OAuthConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
'SourceDefinitionSpecification' : 'com.fasterxml.jackson.databind.JsonNode',
'SourceConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
'DestinationDefinitionSpecification': 'com.fasterxml.jackson.databind.JsonNode',
'DestinationConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
'StreamJsonSchema' : 'com.fasterxml.jackson.databind.JsonNode',
'StateBlob' : 'com.fasterxml.jackson.databind.JsonNode',
'FieldSchema' : 'com.fasterxml.jackson.databind.JsonNode',
]
library = "native"
generateApiDocumentation = false
configOptions = [
dateLibrary : "java8",
generatePom : "false",
interfaceOnly: "true"
]
}
compileJava.dependsOn tasks.generateApiClient
task generateApiDocs(type: GenerateTask) {
def docsOutputDir = "$buildDir/generated/api/docs"
generatorName = "html"
inputSpec = specFile
outputDir = docsOutputDir
apiPackage = "io.airbyte.api.client.generated"
invokerPackage = "io.airbyte.api.client.invoker.generated"
modelPackage = "io.airbyte.api.client.model.generated"
schemaMappings = [
'OAuthConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
'SourceDefinitionSpecification' : 'com.fasterxml.jackson.databind.JsonNode',
'SourceConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
'DestinationDefinitionSpecification': 'com.fasterxml.jackson.databind.JsonNode',
'DestinationConfiguration' : 'com.fasterxml.jackson.databind.JsonNode',
'StreamJsonSchema' : 'com.fasterxml.jackson.databind.JsonNode',
'StateBlob' : 'com.fasterxml.jackson.databind.JsonNode',
'FieldSchema' : 'com.fasterxml.jackson.databind.JsonNode',
]
generateApiDocumentation = false
configOptions = [
dateLibrary : "java8",
generatePom : "false",
interfaceOnly: "true"
]
doLast {
def target = file(rootProject.file("docs/reference/api/generated-api-html"))
delete target
mkdir target
copy {
from outputDir
include "**/*.html"
includeEmptyDirs = false
into target
}
}
}
compileJava.dependsOn tasks.generateApiDocs
dependencies {
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310'
implementation group: 'io.swagger', name: 'swagger-annotations', version: '1.6.2'
implementation group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
implementation group: 'javax.ws.rs', name: 'javax.ws.rs-api', version: '2.1.1'
implementation group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'
implementation group: 'org.openapitools', name: 'jackson-databind-nullable', version: '0.2.1'
}
sourceSets {
main {
java {
srcDirs "$buildDir/generated/api/server/src/gen/java", "$buildDir/generated/api/client/src/main/java", "$projectDir/src/main/java"
}
resources {
srcDir "$projectDir/src/main/openapi/"
}
}
}
Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)