Skip to content

Commit 56ab1df

Browse files
committed
Refactor Gradle build scripts to centralize task configuration.
1 parent a6a64a3 commit 56ab1df

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

api/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import org.gradle.api.tasks.bundling.Jar
21
import org.springframework.boot.gradle.tasks.bundling.BootJar
32

43
val jar: Jar by tasks

build.gradle.kts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
import org.springframework.boot.gradle.tasks.bundling.BootJar
3+
14
plugins {
25
java
36
kotlin("jvm") version "1.9.24" apply false
@@ -12,27 +15,40 @@ subprojects {
1215
apply(plugin = "org.springframework.boot")
1316
apply(plugin = "io.spring.dependency-management")
1417

18+
configureStandardJarTasks()
19+
configureKotlinCompile()
20+
1521
group = "io.github.gunkim.realworld"
1622
version = "0.0.1"
1723

1824
repositories {
1925
mavenCentral()
2026
}
21-
2227
dependencies {
2328
implementation("io.github.oshai:kotlin-logging-jvm:7.0.3")
2429
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
2530
testImplementation("io.kotest:kotest-runner-junit5:5.9.1")
2631
}
2732

28-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
33+
tasks.withType<Test> {
34+
useJUnitPlatform()
35+
}
36+
}
37+
38+
fun Project.configureKotlinCompile() {
39+
tasks.withType<KotlinCompile> {
2940
kotlinOptions {
3041
freeCompilerArgs += "-Xjsr305=strict"
3142
jvmTarget = "21"
3243
}
3344
}
45+
}
3446

35-
tasks.withType<Test> {
36-
useJUnitPlatform()
47+
fun Project.configureStandardJarTasks() {
48+
tasks.named<Jar>("jar") {
49+
enabled = true
50+
}
51+
tasks.named<BootJar>("bootJar") {
52+
enabled = false
3753
}
38-
}
54+
}

core-impl/build.gradle.kts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
import org.gradle.api.tasks.bundling.Jar
2-
import org.springframework.boot.gradle.tasks.bundling.BootJar
3-
4-
val jar: Jar by tasks
5-
val bootJar: BootJar by tasks
6-
7-
bootJar.enabled = false
8-
jar.enabled = true
9-
101
plugins {
112
kotlin("plugin.spring")
123
kotlin("plugin.jpa")

core/build.gradle.kts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
import org.gradle.api.tasks.bundling.Jar
2-
import org.springframework.boot.gradle.tasks.bundling.BootJar
3-
4-
val jar: Jar by tasks
5-
val bootJar: BootJar by tasks
6-
7-
bootJar.enabled = false
8-
jar.enabled = true
9-
101
dependencies {
112
implementation("org.springframework.boot:spring-boot-starter")
123
}

0 commit comments

Comments
 (0)