92 lines
2.2 KiB
Groovy
92 lines
2.2 KiB
Groovy
plugins {
|
|
id 'java'
|
|
id 'org.springframework.boot' version '3.2.5'
|
|
id 'io.spring.dependency-management' version '1.1.5'
|
|
id 'com.github.node-gradle.node' version '7.1.0' apply false
|
|
id 'org.liquibase.gradle' version '2.2.2' apply false
|
|
}
|
|
|
|
group = 'com.example'
|
|
version = '0.0.1-SNAPSHOT'
|
|
description = 'Demo project for Spring Boot'
|
|
|
|
java {
|
|
toolchain {
|
|
languageVersion = JavaLanguageVersion.of(21)
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
ext {
|
|
springdocVersion = "2.2.0"
|
|
h2Version = "2.4.240"
|
|
postgresVersion = "42.7.8"
|
|
liquibaseVersion = "4.33.0"
|
|
|
|
springProfiles = []
|
|
if (project.hasProperty("front")) {
|
|
springProfiles.add("front")
|
|
}
|
|
if (project.hasProperty("prod")) {
|
|
springProfiles.add("prod")
|
|
} else {
|
|
springProfiles.add("dev")
|
|
}
|
|
currentProfiles = springProfiles.join(",")
|
|
logger.quiet("Current profiles are: " + currentProfiles)
|
|
}
|
|
|
|
if (springProfiles.contains("front")) {
|
|
apply from: "build.front.gradle"
|
|
}
|
|
if (springProfiles.contains("dev")) {
|
|
apply from: "build.migrations.gradle"
|
|
}
|
|
|
|
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:${springdocVersion}"
|
|
|
|
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
|
runtimeOnly "org.liquibase:liquibase-core:${liquibaseVersion}"
|
|
|
|
if (springProfiles.contains("prod")) {
|
|
runtimeOnly "org.postgresql:postgresql:${postgresVersion}"
|
|
} else {
|
|
runtimeOnly "org.postgresql:postgresql:${postgresVersion}"
|
|
runtimeOnly "com.h2database:h2:${h2Version}"
|
|
}
|
|
|
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
|
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
|
}
|
|
|
|
bootRun {
|
|
def currentArgs = ["--spring.profiles.active=" + currentProfiles]
|
|
if (project.hasProperty("args")) {
|
|
currentArgs.addAll(project.args.split(","))
|
|
}
|
|
args currentArgs
|
|
}
|
|
|
|
bootJar {
|
|
archiveFileName = String.format("%s-%s.jar", rootProject.name, version)
|
|
}
|
|
|
|
test {
|
|
systemProperty "spring.profiles.active", currentProfiles
|
|
useJUnitPlatform()
|
|
}
|
|
|
|
processResources {
|
|
filesMatching("**/application.yml") {
|
|
filter { line ->
|
|
line.replace("active: dev", "active: ${currentProfiles}")
|
|
}
|
|
}
|
|
}
|