This commit is contained in:
2026-04-28 01:24:04 +09:30
parent 914521f376
commit 29e8a32864
16 changed files with 445 additions and 315 deletions
+111 -2
View File
@@ -4,8 +4,8 @@ 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.springframework.boot") version "4.0.+" apply false
id("io.spring.dependency-management") version "1.1.6"
id("org.sonarqube") version "7.2.3.7755"
}
@@ -88,3 +88,112 @@ configure(subprojects.filter { it.name == "backend" }) {
}
}
}
// Developer helper tasks
tasks.register("createDevProperties") {
group = "developer"
description = "Creates dev.properties file with default values if it doesn't exist"
doLast {
val devPropsFile = File("dev.properties")
if (!devPropsFile.exists()) {
val defaultContent = """
# Development properties
# This file contains configuration values for build and runtime.
# Do not commit this file to the repository.
# Database Configuration
db.url=jdbc:postgresql://localhost:5432/mtgsearch
db.user=postgres
db.password=postgres
db.maxPoolSize=10
# JWT Configuration
jwt.secret=your-secret-key-change-in-production
jwt.expiration=86400
# Application Configuration
app.name=mtg-search
app.version=0.1.0
app.environment=development
# Server Configuration
server.port=8080
server.servlet.contextPath=/
# Frontend Configuration
vite.apiUrl=http://localhost:8080
vite.appTitle=MTG Search
# Logging
log.level=DEBUG
log.dir=logs
""".trimIndent()
devPropsFile.writeText(defaultContent)
println("Created dev.properties with default values")
} else {
println("dev.properties already exists")
}
}
}
tasks.register<Exec>("startPostgres") {
group = "developer"
description = "Starts the PostgreSQL container using docker-compose"
doFirst {
// Check if Docker is available
val dockerCheck = providers.exec {
commandLine("docker", "info")
isIgnoreExitValue = true
}
if (dockerCheck.result.get().exitValue != 0) {
throw GradleException("""
Docker is not available or not running. Please ensure:
1. Docker daemon is running
2. You have permission to access Docker (try 'sudo usermod -aG docker ${'$'}USER' and restart your session)
3. Docker Compose is installed
""".trimIndent())
}
println("Starting PostgreSQL container...")
}
commandLine("docker", "compose", "up", "-d", "postgres")
workingDir = project.rootDir
doLast {
println("PostgreSQL container started. Waiting for it to be healthy...")
// Optional: wait for health check
Thread.sleep(5000) // Simple wait, could be improved
println("PostgreSQL should be ready now.")
}
}
tasks.register<Exec>("stopPostgres") {
group = "developer"
description = "Stops the PostgreSQL container using docker-compose"
doFirst {
// Check if Docker is available
val dockerCheck = providers.exec {
commandLine("docker", "info")
isIgnoreExitValue = true
}
if (dockerCheck.result.get().exitValue != 0) {
throw GradleException("""
Docker is not available or not running. Please ensure:
1. Docker daemon is running
2. You have permission to access Docker (try 'sudo usermod -aG docker ${'$'}USER' and restart your session)
3. Docker Compose is installed
""".trimIndent())
}
println("Stopping PostgreSQL container...")
}
commandLine("docker", "compose", "down")
workingDir = project.rootDir
doLast {
println("PostgreSQL container stopped.")
}
}