1
0
Fork 0

Extract model gen to submodule

This commit is contained in:
Chris Dombroski 2024-11-21 21:42:41 -05:00
parent c6920bb4f7
commit 8ad06a748a
5 changed files with 69 additions and 49 deletions

View file

@ -0,0 +1,67 @@
plugins {
java
id("io.spring.dependency-management") version "1.1.6"
id("org.openapi.generator") version "7.10.0"
idea
}
group = "org.springframework.samples"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
dependencyManagement {
imports {
mavenBom ("org.springframework.boot:spring-boot-dependencies:3.3.6")
}
}
repositories {
mavenCentral()
}
dependencies {
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")
}
tasks.withType<JavaCompile> {
dependsOn(tasks.openApiGenerate)
}
java.sourceSets["main"].java {
srcDir(layout.buildDirectory.dir("generated/sources/openapi/src/main/java"))
}
openApiGenerate {
inputSpec.set("${projectDir}/src/main/resources/openapi.yml")
outputDir.set(layout.buildDirectory.dir("generated/sources/openapi").map { it.asFile.absolutePath })
generatorName.set("spring")
library.set("spring-boot")
modelNameSuffix.set("Dto")
apiPackage.set("org.springframework.samples.petclinic.rest.api")
modelPackage.set("org.springframework.samples.petclinic.rest.dto")
supportingFilesConstrainedTo.set(listOf("ApiUtil.java"))
globalProperties.set(
mapOf(
"apis" to "",
"models" to ""
)
)
configOptions.set(
mutableMapOf(
"verbose" to "true",
"interfaceOnly" to "true",
"performBeanValidation" to "true",
"dateLibrary" to "java8",
"useSpringBoot3" to "true",
"openApiNullable" to "false",
"serializationLibrary" to "jackson",
"documentationProvider" to "springdoc",
)
)
}

13
backend/.gitignore vendored
View file

@ -1,13 +0,0 @@
target/*
.settings/*
.classpath
.project
.idea
*.iml
/target
generated/
# Easier branch switching
springboot-petclinic-client/
springboot-petclinic-server/

View file

@ -2,7 +2,6 @@ plugins {
java
id("org.springframework.boot") version "3.3.6"
id("io.spring.dependency-management") version "1.1.6"
id("org.openapi.generator") version "7.10.0"
idea
jacoco
}
@ -30,7 +29,7 @@ dependencies {
implementation("org.springframework.data:spring-data-jdbc-core:1.2.1.RELEASE")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0")
implementation("org.mapstruct:mapstruct:${project.property("mapstructVersion")}")
// implementation("org.openapitools:jackson-databind-nullable:0.2.6")
implementation(project(":backend-model"))
annotationProcessor("org.mapstruct:mapstruct-processor:${project.property("mapstructVersion")}")
runtimeOnly("org.hsqldb:hsqldb")
testImplementation("org.springframework.boot:spring-boot-starter-test")
@ -39,34 +38,6 @@ dependencies {
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
openApiGenerate {
inputSpec.set("${projectDir}/src/main/resources/openapi.yml")
generatorName.set("spring")
library.set("spring-boot")
modelNameSuffix.set("Dto")
apiPackage.set("org.springframework.samples.petclinic.rest.api")
modelPackage.set("org.springframework.samples.petclinic.rest.dto")
supportingFilesConstrainedTo.set(listOf("ApiUtil.java"))
globalProperties.set(
mapOf(
"apis" to "",
"models" to ""
)
)
configOptions.set(
mutableMapOf(
"verbose" to "true",
"interfaceOnly" to "true",
"performBeanValidation" to "true",
"dateLibrary" to "java8",
"useSpringBoot3" to "true",
"openApiNullable" to "false",
"serializationLibrary" to "jackson",
"documentationProvider" to "springdoc",
)
)
}
tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
classDirectories.setFrom(
@ -106,12 +77,7 @@ tasks.withType<Test> {
}
}
java.sourceSets["main"].java {
srcDir(layout.buildDirectory.dir("generate-resources/main/src/main/java"))
}
tasks.withType<JavaCompile> {
dependsOn(tasks.openApiGenerate)
options.compilerArgs = listOf(
"-Amapstruct.suppressGeneratorTimestamp=true",
"-Amapstruct.suppressGeneratorVersionInfoComment=true",

View file

@ -4,5 +4,5 @@
* The settings file is used to specify which projects to include in your build.
* 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.
*/
include("backend")
rootProject.name = "petclinic"
include("backend", "backend-model")