Extract model gen to submodule
This commit is contained in:
parent
c6920bb4f7
commit
8ad06a748a
5 changed files with 69 additions and 49 deletions
67
backend-model/build.gradle.kts
Normal file
67
backend-model/build.gradle.kts
Normal 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
13
backend/.gitignore
vendored
|
@ -1,13 +0,0 @@
|
||||||
target/*
|
|
||||||
.settings/*
|
|
||||||
.classpath
|
|
||||||
.project
|
|
||||||
.idea
|
|
||||||
*.iml
|
|
||||||
/target
|
|
||||||
|
|
||||||
generated/
|
|
||||||
|
|
||||||
# Easier branch switching
|
|
||||||
springboot-petclinic-client/
|
|
||||||
springboot-petclinic-server/
|
|
|
@ -2,7 +2,6 @@ plugins {
|
||||||
java
|
java
|
||||||
id("org.springframework.boot") version "3.3.6"
|
id("org.springframework.boot") version "3.3.6"
|
||||||
id("io.spring.dependency-management") version "1.1.6"
|
id("io.spring.dependency-management") version "1.1.6"
|
||||||
id("org.openapi.generator") version "7.10.0"
|
|
||||||
idea
|
idea
|
||||||
jacoco
|
jacoco
|
||||||
}
|
}
|
||||||
|
@ -30,7 +29,7 @@ dependencies {
|
||||||
implementation("org.springframework.data:spring-data-jdbc-core:1.2.1.RELEASE")
|
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.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0")
|
||||||
implementation("org.mapstruct:mapstruct:${project.property("mapstructVersion")}")
|
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")}")
|
annotationProcessor("org.mapstruct:mapstruct-processor:${project.property("mapstructVersion")}")
|
||||||
runtimeOnly("org.hsqldb:hsqldb")
|
runtimeOnly("org.hsqldb:hsqldb")
|
||||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||||
|
@ -39,34 +38,6 @@ dependencies {
|
||||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
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 {
|
tasks.jacocoTestReport {
|
||||||
dependsOn(tasks.test) // tests are required to run before generating the report
|
dependsOn(tasks.test) // tests are required to run before generating the report
|
||||||
classDirectories.setFrom(
|
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> {
|
tasks.withType<JavaCompile> {
|
||||||
dependsOn(tasks.openApiGenerate)
|
|
||||||
options.compilerArgs = listOf(
|
options.compilerArgs = listOf(
|
||||||
"-Amapstruct.suppressGeneratorTimestamp=true",
|
"-Amapstruct.suppressGeneratorTimestamp=true",
|
||||||
"-Amapstruct.suppressGeneratorVersionInfoComment=true",
|
"-Amapstruct.suppressGeneratorVersionInfoComment=true",
|
||||||
|
|
|
@ -4,5 +4,5 @@
|
||||||
* The settings file is used to specify which projects to include in your build.
|
* 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.
|
* 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"
|
rootProject.name = "petclinic"
|
||||||
|
include("backend", "backend-model")
|
||||||
|
|
Loading…
Add table
Reference in a new issue