1
- import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2
- import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
3
- import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
4
-
5
1
plugins {
6
2
id " com.github.eirnym.js2p" version " 1.0"
7
- id " de.undercouch.download" version " 5.4.0"
8
3
id " java-library"
9
- id " org.openapi.generator" version " 6.2.1"
10
4
}
11
5
12
6
java {
@@ -28,127 +22,8 @@ compileTestKotlin.compilerOptions.allWarningsAsErrors = false
28
22
spotbugsTest. enabled = false
29
23
spotbugsTestFixtures. enabled = false
30
24
31
- String specFile = " $projectDir /src/main/openapi/config.yaml"
32
- String serverOutputDir = " $buildDir /generated/api/server"
33
- String clientOutputDir = " $buildDir /generated/api/client"
34
- String docsOutputDir = " $buildDir /generated/api/docs"
35
- Map<String ,String > schemaMappingsValue = [
36
- ' OAuthConfiguration' : ' com.fasterxml.jackson.databind.JsonNode' ,
37
- ' SourceDefinitionSpecification' : ' com.fasterxml.jackson.databind.JsonNode' ,
38
- ' SourceConfiguration' : ' com.fasterxml.jackson.databind.JsonNode' ,
39
- ' DestinationDefinitionSpecification' : ' com.fasterxml.jackson.databind.JsonNode' ,
40
- ' DestinationConfiguration' : ' com.fasterxml.jackson.databind.JsonNode' ,
41
- ' StreamJsonSchema' : ' com.fasterxml.jackson.databind.JsonNode' ,
42
- ' StateBlob' : ' com.fasterxml.jackson.databind.JsonNode' ,
43
- ' FieldSchema' : ' com.fasterxml.jackson.databind.JsonNode' ,
44
- ]
45
-
46
25
def generate = tasks. register(' generate' )
47
26
48
- def generateApiServer = tasks. register(' generateApiServer' , GenerateTask ) {
49
-
50
- inputs. file specFile
51
- outputs. dir serverOutputDir
52
-
53
- generatorName = " jaxrs-spec"
54
- inputSpec = specFile
55
- outputDir = serverOutputDir
56
-
57
- apiPackage = " io.airbyte.api.generated"
58
- invokerPackage = " io.airbyte.api.invoker.generated"
59
- modelPackage = " io.airbyte.api.model.generated"
60
-
61
- schemaMappings. set(schemaMappingsValue)
62
-
63
- generateApiDocumentation = false
64
-
65
- configOptions. set([
66
- dateLibrary : " java8" ,
67
- generatePom : " false" ,
68
- interfaceOnly : " true" ,
69
- /*
70
- JAX-RS generator does not respect nullable properties defined in the OpenApi Spec.
71
- 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.
72
- The below Jackson annotation is made to only keep non null values in serialized json.
73
- 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.
74
- Feel free to read the conversation on https://github.com/airbytehq/airbyte/pull/13370 for more details.
75
- */
76
- additionalModelTypeAnnotations : " \n @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)" ,
77
- ])
78
- }
79
- generate. configure {
80
- dependsOn generateApiServer
81
- }
82
-
83
- def generateApiClient = tasks. register(' generateApiClient' , GenerateTask ) {
84
-
85
- inputs. file specFile
86
- outputs. dir clientOutputDir
87
-
88
- generatorName = " java"
89
- inputSpec = specFile
90
- outputDir = clientOutputDir
91
-
92
- apiPackage = " io.airbyte.api.client.generated"
93
- invokerPackage = " io.airbyte.api.client.invoker.generated"
94
- modelPackage = " io.airbyte.api.client.model.generated"
95
-
96
- schemaMappings. set(schemaMappingsValue)
97
-
98
- library = " native"
99
-
100
- generateApiDocumentation = false
101
-
102
- configOptions. set([
103
- dateLibrary : " java8" ,
104
- generatePom : " false" ,
105
- interfaceOnly : " true"
106
- ])
107
- }
108
- generate. configure {
109
- dependsOn generateApiClient
110
- }
111
-
112
- def generateApiDocs = tasks. register(' generateApiDocs' , GenerateTask ) {
113
-
114
- generatorName = " html"
115
- inputSpec = specFile
116
- outputDir = docsOutputDir
117
-
118
- apiPackage = " io.airbyte.api.client.generated"
119
- invokerPackage = " io.airbyte.api.client.invoker.generated"
120
- modelPackage = " io.airbyte.api.client.model.generated"
121
-
122
- schemaMappings. set(schemaMappingsValue)
123
-
124
- generateApiDocumentation = false
125
-
126
- configOptions. set([
127
- dateLibrary : " java8" ,
128
- generatePom : " false" ,
129
- interfaceOnly : " true"
130
- ])
131
- }
132
- def deleteExistingDocs = tasks. register(' deleteOldApiDocs' , Delete ) {
133
- delete rootProject. file(" docs/reference/api/generated-api-html" )
134
- }
135
- deleteExistingDocs. configure {
136
- dependsOn generateApiDocs
137
- }
138
- def copyApiDocs = tasks. register(' copyApiDocs' , Copy ) {
139
- from(docsOutputDir) {
140
- include " **/*.html"
141
- }
142
- into rootProject. file(" docs/reference/api/generated-api-html" )
143
- includeEmptyDirs = false
144
- }
145
- copyApiDocs. configure {
146
- dependsOn deleteExistingDocs
147
- }
148
- generate. configure {
149
- dependsOn copyApiDocs
150
- }
151
-
152
27
dependencies {
153
28
api platform(' com.fasterxml.jackson:jackson-bom:2.15.2' )
154
29
api ' com.fasterxml.jackson.core:jackson-annotations'
@@ -181,6 +56,7 @@ dependencies {
181
56
182
57
testFixturesApi testFixtures(project(' :airbyte-cdk:java:airbyte-cdk:core' ))
183
58
59
+ testFixturesImplementation (' io.airbyte:airbyte-api:0.55.2' ) { transitive = false }
184
60
testFixturesImplementation ' io.swagger:swagger-annotations:1.6.2'
185
61
testFixturesImplementation ' org.apache.ant:ant:1.10.11'
186
62
@@ -209,29 +85,6 @@ generate.configure {
209
85
dependsOn tasks. named(' generateJsonSchema2Pojo' )
210
86
}
211
87
212
-
213
- sourceSets {
214
- main {
215
- java {
216
- srcDirs([
217
- " $projectDir /src/main/java" ,
218
- " ${ serverOutputDir} /src/gen/java" ,
219
- " ${ clientOutputDir} /src/main/java" ,
220
- ])
221
- }
222
- kotlin {
223
- srcDirs([
224
- " $projectDir /src/main/kotlin" ,
225
- " ${ serverOutputDir} /src/gen/kotlin" ,
226
- " ${ clientOutputDir} /src/main/kotlin" ,
227
- ])
228
- }
229
- resources {
230
- srcDir " $projectDir /src/main/openapi/"
231
- }
232
- }
233
- }
234
-
235
88
tasks. named(' compileJava' ). configure {
236
89
dependsOn generate
237
90
}
0 commit comments