@@ -119,27 +119,6 @@ val fatJarArtifact = artifacts.add("archives", fatJarFile) {
119
119
builtBy(" shadowJar" )
120
120
}
121
121
122
- // copies the openAPI specifications from the api folder into a resource
123
- // folder so that they are packaged and deployed with the model-server
124
- val copyApi = tasks.register<Copy >(" copyApi" ) {
125
- dependsOn(openApiSpec)
126
- from(openApiSpec.resolve().first())
127
- into(project.layout.buildDirectory.dir(" openapi/src/main/resources/api" ))
128
- sourceSets[" main" ].resources.srcDir(project.layout.buildDirectory.dir(" openapi/src/main/resources/" ))
129
- }
130
-
131
- tasks.named(" compileKotlin" ) {
132
- dependsOn(copyApi)
133
- }
134
-
135
- tasks.named(" build" ) {
136
- dependsOn(copyApi)
137
- }
138
-
139
- tasks.named(" processResources" ) {
140
- dependsOn(copyApi)
141
- }
142
-
143
122
task(" copyLibs" , Sync ::class ) {
144
123
into(project.layout.buildDirectory.dir(" dependency-libs" ))
145
124
from(configurations.runtimeClasspath)
@@ -209,11 +188,27 @@ spotless {
209
188
}
210
189
}
211
190
191
+ // copies the openAPI specifications from the api folder into a resource
192
+ // folder so that they are packaged and deployed with the model-server
193
+ val specSourceDir = project.layout.buildDirectory.dir(" openapi/src/main/resources" )
194
+ val copyApi = tasks.register<Copy >(" copyApi" ) {
195
+ dependsOn(openApiSpec)
196
+
197
+ from(openApiSpec.resolve().first())
198
+ into(specSourceDir.get().dir(" api" ))
199
+ }
200
+ sourceSets[" main" ].resources.srcDir(specSourceDir)
201
+
202
+ tasks.named(" processResources" ) {
203
+ dependsOn(copyApi)
204
+ }
205
+
212
206
// OpenAPI integration
213
207
val openApiGenerationPath = project.layout.buildDirectory.get().dir(" generated/openapi" )
214
208
val restApiPackage = " org.modelix.model.server.handlers"
215
209
val openApiGenerate = tasks.register<GenerateTask >(" openApiGenerateModelServer" ) {
216
210
dependsOn(openApiSpec)
211
+
217
212
// we let the Gradle OpenAPI generator plugin build data classes and API interfaces based on the provided
218
213
// OpenAPI specification. That way, the code is forced to stay in sync with the API specification.
219
214
generatorName.set(" kotlin-server" )
@@ -254,9 +249,6 @@ val openApiGenerate = tasks.register<GenerateTask>("openApiGenerateModelServer")
254
249
}
255
250
256
251
// Ensure that the OpenAPI generator runs before starting to compile
257
- tasks.named(" processResources" ) {
258
- dependsOn(openApiGenerate)
259
- }
260
252
tasks.named(" compileKotlin" ) {
261
253
dependsOn(openApiGenerate)
262
254
}
0 commit comments