-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle.kts
134 lines (115 loc) · 4.89 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import org.gradle.internal.os.OperatingSystem
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.Properties
val minJavaVersion = JavaVersion.VERSION_11
plugins {
val minJavaVersion = JavaVersion.VERSION_11 // Declared twice because plugins block has its own scope
require(JavaVersion.current() >= minJavaVersion) {
"Building requires at least JDK $minJavaVersion - please look into the README"
}
application
kotlin("jvm") version "1.9.22"
id("org.openjfx.javafxplugin") version "0.0.14"
id("com.github.johnrengelman.shadow") version "6.1.0"
id("com.github.ben-manes.versions") version "0.47.0"
id("se.patrikerdes.use-latest-versions") version "0.2.18"
}
val backend = gradle.includedBuilds.last()
val versionFromBackend by lazy {
val versions = Properties().apply { load(backend.projectDir.resolve("gradle.properties").inputStream()) }
arrayOf("year", "minor", "patch").map { versions["socha.version.$it"].toString().toInt() }.joinToString(".")
}
group = "sc.gui"
version = try {
Runtime.getRuntime().exec(arrayOf("git", "describe", "--tags"))
.inputStream.reader().readText().trim().ifEmpty { null }
} catch(e: java.io.IOException) {
println(e)
} ?: "${versionFromBackend}-${System.getenv("GITHUB_SHA")?.takeUnless { it.isEmpty() } ?: "custom"}"
println("Current version: $version (Java version: ${JavaVersion.current()})")
application {
mainClassName = "sc.gui.GuiAppKt" // needs shadow-update which needs gradle update to 7.0
}
repositories {
mavenCentral()
maven("https://maven.wso2.org/nexus/content/groups/wso2-public/")
maven("https://oss.sonatype.org/content/repositories/snapshots")
}
val debug = project.hasProperty("debug")
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect"))
implementation("no.tornado", "tornadofx", "2.0.0-SNAPSHOT") { exclude("org.jetbrains.kotlin", "kotlin-reflect") }
implementation("ch.qos.logback", "logback-classic", "1.4.11")
implementation("io.github.microutils", "kotlin-logging-jvm", "3.0.5")
implementation("software-challenge", "server")
implementation("software-challenge", "plugin")
implementation("software-challenge", "plugin2025")
if(debug)
implementation("com.tangorabox", "component-inspector-fx", "1.1.0")
}
tasks {
compileJava {
options.release.set(minJavaVersion.majorVersion.toInt())
}
processResources {
if(!debug)
exclude("logback-test.xml")
doLast {
destinationDir.resolve("version.txt").writeText(version.toString())
}
}
withType<KotlinCompile> {
dependsOn(backend.task(":server:deploy"))
kotlinOptions {
jvmTarget = minJavaVersion.toString()
freeCompilerArgs = listOf("-Xjvm-default=all")
}
}
withType<Jar> {
manifest.attributes["Main-Class"] = application.mainClassName
}
javafx {
version = "17.0.8"
val mods = mutableListOf("javafx.base", "javafx.controls", "javafx.fxml")
if(debug)
mods.addAll(listOf("javafx.swing"))
modules = mods
}
shadowJar {
destinationDirectory.set(buildDir)
archiveClassifier.set("${OperatingSystem.current().familyName.replace(" ", "")}-${System.getProperty("os.arch")}")
manifest {
attributes(
"Add-Opens" to arrayOf(
"javafx.controls/javafx.scene.control.skin",
"javafx.controls/javafx.scene.control",
"javafx.graphics/javafx.scene",
// For accessing InputMap used in RangeSliderBehavior
"javafx.controls/com.sun.javafx.scene.control.inputmap",
// Expose list internals for xstream conversion: https://github.com/x-stream/xstream/issues/253
"java.base/java.util").joinToString(" ")
)
}
}
run.configure {
workingDir(buildDir.resolve("tmp"))
doFirst {
workingDir.mkdirs()
}
args = System.getProperty("args", "").split(" ")
}
val release by creating {
dependsOn(clean, check)
group = "distribution"
description = "Create and push a tagged commit matching the backend version"
doLast {
val desc = project.properties["m"]?.toString()
?: throw InvalidUserDataException("Das Argument -Pm=\"Beschreibung dieser Version\" wird benötigt")
exec { commandLine("git", "add", "CHANGELOG.md") }
exec { commandLine("git", "commit", "-m", "release: v$versionFromBackend") }
exec { commandLine("git", "tag", versionFromBackend, "-m", desc) }
exec { commandLine("git", "push", "--follow-tags", "--recurse-submodules=on-demand") }
}
}
}