-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
76 lines (64 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
group = "venediktts"
val versionFile = File("src/main/resources/version.txt")
val gradlePropsFile = File("gradle.properties")
application {
project.setProperty("mainClassName", "catanDiceBot.bot.MainKt")
}
plugins {
kotlin("jvm") version "1.7.10"
application
id("com.github.johnrengelman.shadow") version "6.0.0"
}
repositories {
mavenCentral()
maven("https://jitpack.io")
}
dependencies {
implementation("com.github.elbekD:kt-telegram-bot:2.1.8")
implementation("io.github.microutils:kotlin-logging-jvm:3.0.4")
implementation("ch.qos.logback:logback-classic:1.3.0")
}
tasks.register("writeVersion") {
group = "build"
doFirst {
println("Writing version to ${versionFile.path}")
versionFile.writeText(version.toString())
}
}
tasks.register("incrementVersion") {
group = "build"
doFirst {
val versionString = version.toString()
val buildNumberStart = versionString.lastIndexOf('.') + 1
val buildNumber = versionString.substring(buildNumberStart)
.toInt()
.plus(1)
val versionExceptBuildNumber = versionString.substring(0, buildNumberStart)
val newVersionString = versionExceptBuildNumber + buildNumber
println("Incrementing version at ${gradlePropsFile.path}")
gradlePropsFile.writeText(
gradlePropsFile.readText()
.replace("version=$versionString", "version=$newVersionString")
)
}
}
tasks.register("release") {
group = "build"
dependsOn("incrementVersion", "shadowJar")
}
tasks.test {
useJUnitPlatform()
}
tasks.withType(ShadowJar::class) {
mustRunAfter("incrementVersion")
archiveFileName.set("catan-dice-bot-${archiveVersion.get()}.${archiveExtension.get()}")
}
tasks.withType<KotlinCompile> {
dependsOn("writeVersion")
kotlinOptions.jvmTarget = "1.8"
}
application {
mainClass.set("MainKt")
}