Skip to content

Commit

Permalink
[PoC] Gradle Version Catalog 사용해보기 (#429)
Browse files Browse the repository at this point in the history
* chore: try gradle version catalog

* chore: use type-safe plugin id
  • Loading branch information
jyoo0515 authored Nov 26, 2024
1 parent 42d2056 commit 7a76a2a
Show file tree
Hide file tree
Showing 31 changed files with 218 additions and 256 deletions.
49 changes: 23 additions & 26 deletions app-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.tasks.bundling.BootJar

plugins {
kotlin("jvm")
kotlin("plugin.spring")
kotlin("plugin.jpa")
id("org.springframework.boot")
id("io.gitlab.arturbosch.detekt")
id("io.spring.dependency-management")
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.spring)
alias(libs.plugins.kotlin.jpa)
alias(libs.plugins.spring.boot)
alias(libs.plugins.detekt)
alias(libs.plugins.spring.dependency.management)
}

repositories {
Expand All @@ -28,9 +28,12 @@ val detektExcludedProjects = listOf(
project(":deploying_apps:local_script"),
)
subprojects {
apply(plugin = "kotlin")
apply(plugin = "kotlin-spring")
apply(plugin = "kotlin-jpa")
apply {
plugin(rootProject.libs.plugins.kotlin.jvm.get().pluginId)
plugin(rootProject.libs.plugins.kotlin.spring.get().pluginId)
plugin(rootProject.libs.plugins.kotlin.jpa.get().pluginId)
plugin(rootProject.libs.plugins.spring.dependency.management.get().pluginId)
}

noArg {
annotation("club.staircrusher.stdlib.persistence.jpa.NoArgsConstructor")
Expand All @@ -43,6 +46,12 @@ subprojects {
annotation("club.staircrusher.stdlib.di.annotation.Component")
}

dependencyManagement {
imports {
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
}
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
Expand All @@ -61,12 +70,7 @@ subprojects {
} else if (project.name == "application") {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
}
val kotlinLoggingVersion: String by project
val kotlinSerialization: String by project
val kotlinVersion: String by project
implementation("io.github.microutils:kotlin-logging-jvm:$kotlinLoggingVersion")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinSerialization")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
implementation(rootProject.libs.bundles.kotlin.subproject)
}

tasks.test {
Expand All @@ -87,7 +91,9 @@ subprojects {
}

if (this !in detektExcludedProjects) {
apply(plugin = "io.gitlab.arturbosch.detekt")
apply {
plugin(rootProject.libs.plugins.detekt.get().pluginId)
}

detekt {
config = files("$rootDir/detekt-config.yml")
Expand All @@ -106,14 +112,6 @@ subprojects {
}
}
}


apply(plugin = "io.spring.dependency-management")
dependencyManagement {
imports {
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
}
}
}

/**
Expand Down Expand Up @@ -153,12 +151,11 @@ subprojects {
}
}

val coroutineVersion: String by project
listOfNotNull(domainProject, applicationProject, infraProject)
.forEach {
it.dependencies {
implementation(rootProject.projects.crossCuttingConcern.stdlib)
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")
implementation(rootProject.libs.coroutines.core)
}
}
}
Expand Down
27 changes: 0 additions & 27 deletions app-server/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,31 +1,4 @@
kotlin.code.style=official
kotlinVersion=1.8.20
kotlinxSerializationVersion=1.5.0
kotlinLoggingVersion=3.0.5
kotlinSerialization=1.5.1
jakartaInjectVersion=2.0.1
springBootVersion=3.0.5
springDependencyManagementVersion=1.1.0
springContextVersion=6.0.7
coroutineVersion=1.6.4
jUnitJupiterVersion=5.9.1
wireVersion=4.4.1
geoToolsVersion=26.5
jtsVersion=1.19.0
proj4jVersion=1.3.0
postgresqlVersion=42.5.0
flywayVersion=9.4.0
kspVersion=1.8.20-1.0.10
kopyKatVersion=1.0.4
detektVersion=1.21.0
jibVersion=3.4.1
jacksonModuleKotlinVersion=2.12.3
awsSdkVersion=2.17.292
guavaVersion=31.1-jre
sentryVersion=6.7.0
logbackJsonVersion=0.1.5
firebaseAdminVersion=9.3.0
apacheCommonsVersion=1.11.0

# gradle config
org.gradle.jvmargs=-Xmx8g
Expand Down
82 changes: 82 additions & 0 deletions app-server/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
[versions]
# plugins
kotlin = "1.8.20"
springBoot = "3.0.5"
springDependencyManagement = "1.1.0"
detekt = "1.21.0"
ksp = "1.8.20-1.0.10"
jib = "3.4.1"
openapiGenerator = "6.0.1"

# libraries
kotlinLogging = "3.0.5"
kotlinSerialization = "1.5.1"
coroutine = "1.6.4"
geoTools = "26.5"
jts = "1.19.0"
proj4j = "1.3.0"
kopykat = "1.0.4"
apacheCommons = "1.11.0"
jUnitJupiter = "5.9.1"
jacksonModuleKotlin = "2.12.3"
awsSdk = "2.17.292"
guava = "31.1-jre"
firebaseAdmin = "9.3.0"
sentry = "6.7.0"
logback = "0.1.5"
postgresql = "42.5.0"
flyway = "9.4.0"
jwt = "3.18.1"
mockitoKotlin = "5.1.0"

[libraries]
kotlin-logging = { group = "io.github.microutils", name = "kotlin-logging-jvm", version.ref = "kotlinLogging" }
kotlin-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinSerialization" }
kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" }
kotlin-stdlib-jdk8 = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlin" }
coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutine" }
coroutines-reactive = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-reactive", version.ref = "coroutine" }
coroutines-jdk8 = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-jdk8", version.ref = "coroutine" }
coroutines-guava = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-guava", version.ref = "coroutine" }
coroutines-reactor = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-reactor", version.ref = "coroutine" }
geotools-referencing = { group = "org.geotools", name = "gt-referencing", version.ref = "geoTools" }
jts-core = { group = "org.locationtech.jts", name = "jts-core", version.ref = "jts" }
proj4j-core = { group = "org.locationtech.proj4j", name = "proj4j", version.ref = "proj4j" }
proj4j-epsg = { group = "org.locationtech.proj4j", name = "proj4j-epsg", version.ref = "proj4j" }
kopykat-ksp = { group = "at.kopyk", name = "kopykat-ksp", version.ref = "kopykat" }
kopykat-annotations = { group = "at.kopyk", name = "kopykat-annotations", version.ref = "kopykat" }
apache-commons-text = { group = "org.apache.commons", name = "commons-text", version.ref = "apacheCommons" }
apache-commons-csv = { group = "org.apache.commons", name = "commons-csv", version.ref = "apacheCommons" }
junit-jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "jUnitJupiter" }
junit-jupiter-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "jUnitJupiter" }
jackson-module-kotlin = { group = "com.fasterxml.jackson.module", name = "jackson-module-kotlin", version.ref = "jacksonModuleKotlin" }
aws-sdk-s3 = { group = "software.amazon.awssdk", name = "s3", version.ref = "awsSdk" }
aws-sdk-rekognition = { group = "software.amazon.awssdk", name = "rekognition", version.ref = "awsSdk" }
aws-sdk-sts = { group = "software.amazon.awssdk", name = "sts", version.ref = "awsSdk" }
guava = { group = "com.google.guava", name = "guava", version.ref = "guava" }
firebase-admin = { group = "com.google.firebase", name = "firebase-admin", version.ref = "firebaseAdmin" }
sentry-spring-boot-starter = { group = "io.sentry", name = "sentry-spring-boot-starter-jakarta", version.ref = "sentry" }
sentry-logback = { group = "io.sentry", name = "sentry-logback", version.ref = "sentry" }
logback-jackson = { group = "ch.qos.logback.contrib", name = "logback-jackson", version.ref = "logback" }
logback-json-classic = { group = "ch.qos.logback.contrib", name = "logback-jackson", version.ref = "logback" }
flyway-core = { group = "org.flywaydb", name = "flyway-core", version.ref = "flyway" }
postgresql = { group = "org.postgresql", name = "postgresql", version.ref = "postgresql" }
java-jwt = { group = "com.auth0", name = "java-jwt", version.ref = "jwt" }
mockito-kotlin = { group = "org.mockito.kotlin", name = "mockito-kotlin", version.ref = "mockitoKotlin" }

[bundles]
kotlin-subproject = ["kotlin-logging", "kotlin-serialization-json", "kotlin-reflect"]
sentry = ["sentry-spring-boot-starter", "sentry-logback"]
logback = ["logback-jackson", "logback-json-classic"]

[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kotlin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" }
kotlin-jpa = { id = "org.jetbrains.kotlin.plugin.jpa", version.ref = "kotlin" }
spring-boot = { id = "org.springframework.boot", version.ref = "springBoot" }
spring-dependency-management = { id = "io.spring.dependency-management", version.ref = "springDependencyManagement" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
jib = { id = "com.google.cloud.tools.jib", version.ref = "jib" }
openapi-generator = { id = "org.openapi.generator", version.ref = "openapiGenerator" }
24 changes: 0 additions & 24 deletions app-server/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,6 @@ fileTree("subprojects").filter { it.name == "build.gradle.kts" }.forEach {


pluginManagement {
val kotlinVersion: String by settings
val springBootVersion: String by settings
val springDependencyManagementVersion: String by settings
val wireVersion: String by settings
val kspVersion: String by settings
val detektVersion: String by settings
val jibVersion: String by settings

plugins {
kotlin("jvm") version kotlinVersion
kotlin("plugin.serialization") version kotlinVersion
kotlin("plugin.spring") version kotlinVersion apply false
kotlin("plugin.jpa") version kotlinVersion apply false

id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
id("org.springframework.boot") version springBootVersion
id("com.squareup.wire") version wireVersion
id("com.google.devtools.ksp") version kspVersion
id("io.gitlab.arturbosch.detekt") version detektVersion
id("com.google.cloud.tools.jib") version jibVersion

id("io.spring.dependency-management") version springDependencyManagementVersion
}

repositories {
mavenCentral()
gradlePluginPortal()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
val kotlinVersion: String by project

plugins {
kotlin("jvm")
id("org.openapi.generator") version "6.0.1"
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.openapi.generator)
}

dependencies {
Expand Down Expand Up @@ -44,9 +42,9 @@ tasks.getByName("compileKotlin").dependsOn(openApiGenerateTask)

// openApiGenerateTask로 생성된 build.gradle.kts의 dependencies를 여기에 복사한다.
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.3")
implementation(libs.kotlin.stdlib.jdk8)
implementation(libs.kotlin.reflect)
implementation(libs.jackson.module.kotlin)
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.3")
implementation("com.squareup.okhttp3:okhttp:4.9.1")
}
12 changes: 5 additions & 7 deletions app-server/subprojects/api_specification/api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
val kotlinVersion: String by project

plugins {
kotlin("jvm")
id("org.openapi.generator") version "6.0.1"
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.openapi.generator)
}

dependencies {
Expand Down Expand Up @@ -44,9 +42,9 @@ tasks.getByName("compileKotlin").dependsOn(openApiGenerateTask)

// openApiGenerateTask로 생성된 build.gradle.kts의 dependencies를 여기에 복사한다.
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.3")
implementation(libs.kotlin.stdlib.jdk8)
implementation(libs.kotlin.reflect)
implementation(libs.jackson.module.kotlin)
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.3")
implementation("com.squareup.okhttp3:okhttp:4.9.1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
implementation("org.sejda.webp-imageio:webp-imageio-sejda:0.1.0")
implementation("org.bytedeco:javacv-platform:1.5.9")

testImplementation("org.mockito.kotlin:mockito-kotlin:5.1.0")
testImplementation(libs.mockito.kotlin)

integrationTestImplementation(projects.crossCuttingConcern.test.springIt)
integrationTestImplementation("org.springframework.boot:spring-boot-starter-web")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
dependencies {
val jacksonModuleKotlinVersion: String by project
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonModuleKotlinVersion")
implementation(libs.jackson.module.kotlin)

val jUnitJupiterVersion: String by project
testImplementation("org.junit.jupiter:junit-jupiter-api:$jUnitJupiterVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$jUnitJupiterVersion")
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.jupiter.engine)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("io.spring.dependency-management")
id("org.springframework.boot")
alias(libs.plugins.spring.dependency.management)
alias(libs.plugins.spring.boot)
}

dependencies {
Expand All @@ -14,14 +14,13 @@ dependencies {
implementation(projects.crossCuttingConcern.infra.persistenceModel)
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework:spring-webflux")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8")
implementation(libs.coroutines.jdk8)

integrationTestImplementation(projects.crossCuttingConcern.test.springIt)

val awsSdkVersion: String by project
implementation("software.amazon.awssdk:s3:$awsSdkVersion")
implementation("software.amazon.awssdk:rekognition:$awsSdkVersion")
runtimeOnly("software.amazon.awssdk:sts:$awsSdkVersion") // IRSA를 사용하기 위해서 필요함
implementation(libs.aws.sdk.s3)
implementation(libs.aws.sdk.rekognition)
runtimeOnly(libs.aws.sdk.sts) // IRSA를 사용하기 위해서 필요함
testImplementation(projects.apiSpecification.domainEvent)
testImplementation("org.mockito.kotlin:mockito-kotlin:5.1.0")
testImplementation(libs.mockito.kotlin)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ dependencies {
implementation(projects.boundedContext.place.domain)

implementation("org.hibernate.orm:hibernate-core")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation(libs.jackson.module.kotlin)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("io.spring.dependency-management")
id("org.springframework.boot")
alias(libs.plugins.spring.dependency.management)
alias(libs.plugins.spring.boot)
}

dependencies {
Expand All @@ -11,9 +11,8 @@ dependencies {

integrationTestImplementation(projects.crossCuttingConcern.test.springIt)

val awsSdkVersion: String by project
implementation("software.amazon.awssdk:s3:$awsSdkVersion")
runtimeOnly("software.amazon.awssdk:sts:$awsSdkVersion") // IRSA를 사용하기 위해서 필요함
implementation(libs.aws.sdk.s3)
runtimeOnly(libs.aws.sdk.sts) // IRSA를 사용하기 위해서 필요함

testImplementation(projects.boundedContext.place.application)
}
Loading

0 comments on commit 7a76a2a

Please sign in to comment.