Files
mtg-search/build.gradle.kts
T
2026-04-27 23:35:34 +09:30

91 lines
3.4 KiB
Kotlin

import org.gradle.api.tasks.testing.logging.TestLogEvent
import java.util.Properties
import java.io.File
plugins {
id("java")
id("org.springframework.boot") version "3.2.5" apply false
id("io.spring.dependency-management") version "1.1.4"
id("org.sonarqube") version "7.2.3.7755"
}
sonar {
properties {
property("sonar.projectKey", "MTGSearch")
property("sonar.projectName", "MTGSearch")
property("sonar.qualitygate.wait", true)
}
}
group = "net.moustos"
version = "0.1.0"
// Load dev.properties if it exists
val devPropsFile = File("dev.properties")
val devProps = Properties().apply {
if (devPropsFile.exists()) {
load(devPropsFile.inputStream())
}
}
// Define properties with defaults, preferring env vars over dev.properties
val propertiesMap = mapOf(
"db.url" to (System.getenv("DB_URL") ?: devProps.getProperty("db.url", "jdbc:postgresql://localhost:5432/mtgsearch")),
"db.user" to (System.getenv("DB_USER") ?: devProps.getProperty("db.user", "postgres")),
"db.password" to (System.getenv("DB_PASSWORD") ?: devProps.getProperty("db.password", "postgres")),
"db.maxPoolSize" to (System.getenv("DB_MAX_POOL_SIZE") ?: devProps.getProperty("db.maxPoolSize", "10")),
"jwt.secret" to (System.getenv("JWT_SECRET") ?: devProps.getProperty("jwt.secret", "your-secret-key-change-in-production")),
"jwt.expiration" to (System.getenv("JWT_EXPIRATION") ?: devProps.getProperty("jwt.expiration", "86400")),
"app.name" to (System.getenv("APP_NAME") ?: devProps.getProperty("app.name", "mtg-search")),
"app.version" to (System.getenv("APP_VERSION") ?: devProps.getProperty("app.version", "0.1.0")),
"app.environment" to (System.getenv("APP_ENVIRONMENT") ?: devProps.getProperty("app.environment", "development")),
"server.port" to (System.getenv("SERVER_PORT") ?: devProps.getProperty("server.port", "8080")),
"server.servlet.contextPath" to (System.getenv("SERVER_SERVLET_CONTEXT_PATH") ?: devProps.getProperty("server.servlet.contextPath", "/")),
"vite.apiUrl" to (System.getenv("VITE_API_URL") ?: devProps.getProperty("vite.apiUrl", "http://localhost:8080")),
"vite.appTitle" to (System.getenv("VITE_APP_TITLE") ?: devProps.getProperty("vite.appTitle", "MTG Search")),
"log.level" to (System.getenv("LOG_LEVEL") ?: devProps.getProperty("log.level", "DEBUG")),
"log.dir" to (System.getenv("LOG_DIR") ?: devProps.getProperty("log.dir", "logs"))
)
// Set system properties for Spring Boot
propertiesMap.forEach { (key, value) ->
System.setProperty(key, value)
}
// Also set as project extra for Gradle use
propertiesMap.forEach { (key, value) ->
extra.set(key, value)
}
allprojects {
repositories {
mavenCentral()
maven {
url = uri("https://repo.maven.apache.org/maven2/")
}
}
}
configure(subprojects.filter { it.name == "backend" }) {
apply(plugin = "java")
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.compilerArgs.add("-parameters")
}
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
showStandardStreams = false
}
}
}