-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
163 lines (141 loc) · 5.81 KB
/
build.gradle.kts
File metadata and controls
163 lines (141 loc) · 5.81 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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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.25"
id("idea")
id("org.openjfx.javafxplugin") version "0.1.0"
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"
}
idea {
module {
isDownloadSources = true
isDownloadJavadoc = true
}
}
val backend = gradle.includedBuilds.last()
val versionFromBackend by lazy {
val versions = Properties().apply { load(backend.projectDir.resolve("gradle.properties").inputStream()) }
val suffix = versions["socha.version.suffix"].toString().takeUnless { it.isBlank() }?.let { "-$it" }.orEmpty()
arrayOf("year", "minor", "patch").map { versions["socha.version.$it"].toString().toInt() }.joinToString(".") + suffix
}
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/")
// TornadoFX
// maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://jitpack.io")
}
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("com.github.software-challenge.tornadofx2", "tornadofx2", "2.0.0")
// implementation("com.github.edvin", "tornadofx2", "master-SNAPSHOT")
// implementation("com.github.edvin", "tornadofx2", "21e933fd41")
implementation(files("./gradle/tornadofx2-21e933fd41.jar"))
implementation("ch.qos.logback", "logback-classic", "1.5.18")
implementation("io.github.oshai", "kotlin-logging-jvm", "6.0.9") // TODO version 7 with kotlin 2
implementation("software-challenge", "server")
implementation("software-challenge", "plugin2024")
implementation("software-challenge", "plugin2025")
implementation("software-challenge", "plugin")
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> {
kotlinOptions {
jvmTarget = minJavaVersion.toString()
freeCompilerArgs = listOf("-Xjvm-default=all")
}
}
withType<Jar> {
manifest.attributes["Main-Class"] = application.mainClassName
}
javafx {
version = "17.0.15"
val mods = mutableListOf(
"javafx.base", "javafx.controls", "javafx.fxml",
"javafx.web", "javafx.media", "javafx.swing"
) // included because of tornadofx already
// 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(" ")
)
}
mergeServiceFiles() // This requires downgrading to JDK 11 to function properly!
}
run.configure {
dependsOn(backend.task(":server:makeRunnable"))
workingDir(buildDir.resolve("run"))
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") }
}
}
}