diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 10d371c07..94834d8b6 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -46,6 +46,9 @@ tasks.register("copySubProjectsOpenAPIFiles") { // By convention, we expect OpenAPI files for sub-projects to be named and placed as follows: // /src/main/openapi/.yaml // For example: organization/src/main/openapi/organization.yaml + // Get the order from settings.gradle.kts include() declaration + val moduleOrder = rootProject.subprojects.map { it.name } + val sourcePaths = configurations.implementation .get() @@ -60,6 +63,12 @@ tasks.register("copySubProjectsOpenAPIFiles") { .map { file("${it}/src/main/openapi/${it.relativeTo(rootDir)}.yaml") } .filter { it.exists() } .map { it.absolutePath } + .sortedBy { path -> + // Extract module name from path and find its index in the desired order + val moduleName = file(path).parentFile.parentFile.parentFile.name + val index = moduleOrder.indexOf(moduleName) + if (index >= 0) index else Int.MAX_VALUE // Put unknown modules at the end + } .toMutableList() // If you need to reference a non-conventional path, feel free to add it below to the // sourcePaths local variable, like so: sourcePaths.add("my/path/to/another/openapi.yaml") diff --git a/settings.gradle.kts b/settings.gradle.kts index c3db77d46..c11804768 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -15,7 +15,7 @@ pluginManagement { rootProject.name = "cosmotech-api-parent" include( - "api", "meta", "dataset", "organization", "solution", "workspace", "metrics", "runner", "run") + "api", "organization", "solution", "workspace", "dataset", "runner", "run", "meta", "metrics") project(":api").name = "cosmotech-api"