-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
73 lines (56 loc) · 1.75 KB
/
build.gradle.kts
File metadata and controls
73 lines (56 loc) · 1.75 KB
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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
plugins {
kotlin("jvm") version "1.7.10"
id("com.github.johnrengelman.shadow") version "7.1.2"
id("com.bmuschko.docker-remote-api") version "6.7.0"
application
}
repositories {
mavenCentral()
}
dependencies {
testImplementation(kotlin("test"))
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}
application {
mainClass.set("MainKt")
}
tasks.jar {
manifest {
attributes(mapOf(
"Main-Class" to application.mainClass
))
}
}
val shadowJarFileName = "${project.name}-${project.version}.jar"
tasks.shadowJar {
dependsOn(tasks.jar)
// See https://imperceptiblethoughts.com/shadow/configuration/#configuring-output-name
archiveFileName.set(shadowJarFileName)
}
tasks.distTar { dependsOn(tasks.shadowJar) }
tasks.distZip { dependsOn(tasks.shadowJar) }
tasks.startScripts { dependsOn(tasks.shadowJar) }
/**
* See https://bmuschko.github.io/gradle-docker-plugin/api/com/bmuschko/gradle/docker/tasks/image/DockerBuildImage.html
*/
tasks.create("buildImage", DockerBuildImage::class) {
dependsOn(tasks.build)
buildArgs.set(mapOf("SHADOW_JAR_FILE_NAME" to shadowJarFileName))
// defines the docker build context
inputDir.set(project.projectDir)
val imageRepository = project.properties["imageRepository"]!!
val imageName = project.properties["imageName"] ?: project.name
val tagVersion = "$imageRepository/$imageName:${project.version}"
val tagLatest = "$imageRepository/$imageName:latest"
images.add(tagVersion)
if (project.hasProperty("createLatestTag")) {
images.add(tagLatest)
}
}