Skip to content

Commit 1381ae2

Browse files
committed
build(model-server): reduce task dependencies
Removes dependencies that are not explicitly required. The original reason for the additional dependencies was making ktlint tasks happy. But they have been dropped from the build.
1 parent fd7833f commit 1381ae2

File tree

1 file changed

+16
-24
lines changed

1 file changed

+16
-24
lines changed

model-server/build.gradle.kts

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -119,27 +119,6 @@ val fatJarArtifact = artifacts.add("archives", fatJarFile) {
119119
builtBy("shadowJar")
120120
}
121121

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-
143122
task("copyLibs", Sync::class) {
144123
into(project.layout.buildDirectory.dir("dependency-libs"))
145124
from(configurations.runtimeClasspath)
@@ -209,11 +188,27 @@ spotless {
209188
}
210189
}
211190

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+
212206
// OpenAPI integration
213207
val openApiGenerationPath = project.layout.buildDirectory.get().dir("generated/openapi")
214208
val restApiPackage = "org.modelix.model.server.handlers"
215209
val openApiGenerate = tasks.register<GenerateTask>("openApiGenerateModelServer") {
216210
dependsOn(openApiSpec)
211+
217212
// we let the Gradle OpenAPI generator plugin build data classes and API interfaces based on the provided
218213
// OpenAPI specification. That way, the code is forced to stay in sync with the API specification.
219214
generatorName.set("kotlin-server")
@@ -254,9 +249,6 @@ val openApiGenerate = tasks.register<GenerateTask>("openApiGenerateModelServer")
254249
}
255250

256251
// Ensure that the OpenAPI generator runs before starting to compile
257-
tasks.named("processResources") {
258-
dependsOn(openApiGenerate)
259-
}
260252
tasks.named("compileKotlin") {
261253
dependsOn(openApiGenerate)
262254
}

0 commit comments

Comments
 (0)