-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
162 lines (142 loc) · 4.84 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
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
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.time.Instant
import java.time.format.DateTimeFormatter
import kotlin.text.replace
plugins {
alias(libs.plugins.org.jetbrains.kotlin.jvm)
alias(libs.plugins.org.jetbrains.kotlin.plugin.serialization)
application
alias(libs.plugins.org.javamodularity.moduleplugin)
alias(libs.plugins.org.beryx.jlink)
}
group = "com.github.lure0xaos.jrpycg"
version = "1.0.0"
description = ""
val appMainClass: String = "com.github.lure0xaos.jrpycg.RPyCG"
val appModule: String = "RPyCG"
val appName: String = "RPyCG"
val os: org.gradle.internal.os.OperatingSystem = org.gradle.internal.os.OperatingSystem.current()
val appIconIco: String = "src/main/resources/com/github/lure0xaos/jrpycg/ui/RPyCGFrame.ico"
val appIconPng: String = "src/main/resources/com/github/lure0xaos/jrpycg/ui/RPyCGFrame.png"
val appCopyright: String = "Lure of Chaos"
val appVendor: String = "Lure of Chaos"
repositories {
mavenCentral()
}
dependencies {
implementation(project.dependencies.enforcedPlatform(libs.org.jetbrains.kotlin.kotlin.bom))
implementation(libs.org.jetbrains.kotlin.kotlin.reflect)
testImplementation(libs.org.jetbrains.kotlin.kotlin.test)
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(libs.versions.java.get())
}
}
tasks.compileJava {
modularity.inferModulePath.set(true)
sourceCompatibility = libs.versions.java.get()
targetCompatibility = libs.versions.java.get()
}
tasks.compileKotlin {
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(libs.versions.java.get()))
}
}
application {
mainClass.set(appMainClass)
mainModule.set(appModule)
}
tasks.processResources {
filesMatching(listOf("**/*.properties")) {
filter { line ->
val transform: (MatchResult) -> CharSequence = { result ->
result.groups[1]?.value?.let { key ->
when {
key == "project.name" -> appName
key == "project.version" -> project.version.toString()
key == "project.description" -> project.description
key == "timestamp" -> DateTimeFormatter.ofPattern("yyyyMMdd-HHmm").format(Instant.now())
project.extra.has(key) -> project.extra.get(key)?.toString()
else -> null
}
} ?: result.groups[0]?.value.toString()
}
line.replace(Regex("\\$\\{([^}]+)\\}"), transform).replace(Regex("@([^@]+)@"), transform)
}
}
}
jlink {
options.set(listOf("--strip-debug", "--no-header-files", "--no-man-pages"))
launcher {
name = appName
mainClass.set(appMainClass)
}
jpackage {
installerType = when {
os.isWindows -> "msi"
os.isLinux -> "rpm"
os.isMacOsX -> "dmg"
else -> error("unsupported OS: $os")
}
installerName = appName
appVersion = project.version.toString()
when {
os.isWindows -> {
icon = rootProject.file(appIconIco).path
installerOptions = listOf(
"--description", rootProject.description,
"--copyright", appCopyright,
"--vendor", appVendor,
"--win-dir-chooser",
"--win-menu",
"--win-menu-group", rootProject.name,
"--win-per-user-install",
"--win-shortcut"
)
}
os.isLinux -> {
icon = rootProject.file(appIconPng).path
installerOptions = listOf(
"--description", rootProject.description,
"--copyright", appCopyright,
"--vendor", appVendor,
"--linux-menu-group", rootProject.name,
"--linux-shortcut"
)
}
os.isMacOsX -> {
icon = rootProject.file(appIconPng).path
}
}
installerOptions = listOf("--verbose")
}
}
tasks.build {
// dependsOn += tasks.jpackage
}
tasks.test {
useJUnitPlatform()
extensions.configure(org.javamodularity.moduleplugin.extensions.TestModuleOptions::class) {
runOnClasspath = true
}
}
tasks.compileTestJava {
modularity.inferModulePath.set(true)
extensions.configure(org.javamodularity.moduleplugin.extensions.CompileTestModuleOptions::class) {
isCompileOnClasspath = true
}
}
tasks.compileTestKotlin {
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(libs.versions.java.get()))
}
}
tasks.jpackage {
doLast {
println(
"packaged in " + uri("" + jpackageData.installerOutputDir)
.toURL().toExternalForm().replace("file:/", "file:///")
)
}
}