/
build.gradle.kts
85 lines (71 loc) · 2 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import org.apache.tools.ant.filters.ReplaceTokens
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage
plugins {
java
id("org.springframework.boot") version "3.2.2"
id("io.spring.dependency-management") version "1.1.4"
id("com.diffplug.spotless") version "6.25.0"
id("net.researchgate.release") version "3.0.2"
}
group = "com.example"
version = "0.0.1-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_21
}
tasks.withType<ProcessResources> {
filesMatching("**/banner.txt") {
filter<ReplaceTokens>("tokens" to mapOf("project.version" to project.version))
}
}
spotless {
java {
googleJavaFormat()
}
kotlin {
target("buildSrc/src/main/kotlin/**")
ktfmt()
}
kotlinGradle {
ktlint()
}
}
tasks.named("spotlessCheck").configure {
dependsOn("spotlessApply")
}
configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
compileOnly("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.apache.commons:commons-lang3")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
var gitHash = project.getGitSHA()
var releasing = false
gradle.taskGraph.whenReady{
if(this.allTasks.contains(tasks.getByName("release"))){
releasing = true
}
}
tasks.named("bootBuildImage",BootBuildImage::class) {
var tag = version.toString()
if (!releasing) {
tag += gitHash
}
imageName = "ghcr.io/fraucamidokura/spring_builder_tool/task-sample:${tag}"
}
tasks.register<DockerPushTask>("bootPushImage") {
imageName = tasks.named("bootBuildImage",BootBuildImage::class).get().imageName
dependsOn("bootBuildImage")
}
tasks.named("beforeReleaseBuild"){
dependsOn("bootPushImage")
}