diff --git a/api/build.gradle.kts b/api/build.gradle.kts new file mode 100644 index 0000000..80f18d6 --- /dev/null +++ b/api/build.gradle.kts @@ -0,0 +1,16 @@ +plugins { +} + +group = "org.springframework.samples" + +val apiArtifact by configurations.creating { + isCanBeResolved = false +} + +repositories { + mavenCentral() +} + +artifacts { + add(apiArtifact.name, file("${projectDir}/openapi.yml")) +} \ No newline at end of file diff --git a/backend-model/src/main/resources/openapi.yml b/api/openapi.yml similarity index 100% rename from backend-model/src/main/resources/openapi.yml rename to api/openapi.yml diff --git a/backend-model/build.gradle.kts b/backend-model/build.gradle.kts index 73b5b24..f080b80 100644 --- a/backend-model/build.gradle.kts +++ b/backend-model/build.gradle.kts @@ -7,6 +7,10 @@ plugins { group = "org.springframework.samples" +val apiArtifact by configurations.creating { + isCanBeConsumed = false +} + java { toolchain { languageVersion = JavaLanguageVersion.of(21) @@ -24,6 +28,7 @@ repositories { } dependencies { + apiArtifact(project(":api", "apiArtifact")) implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0") @@ -38,7 +43,7 @@ java.sourceSets["main"].java { } openApiGenerate { - inputSpec.set("${projectDir}/src/main/resources/openapi.yml") + inputSpec.set(apiArtifact.singleFile.absolutePath) outputDir.set(layout.buildDirectory.dir("generated/sources/openapi").map { it.asFile.absolutePath }) generatorName.set("spring") library.set("spring-boot") diff --git a/settings.gradle.kts b/settings.gradle.kts index b730a22..ca4b1a3 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,4 +5,4 @@ * For more detailed information on multi-project builds, please refer to https://docs.gradle.org/8.7/userguide/multi_project_builds.html in the Gradle documentation. */ rootProject.name = "petclinic" -include("backend", "backend-model") +include("backend", "backend-model", "api")