-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
306 lines (247 loc) · 10.6 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
import com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URL
plugins {
application
kotlin("jvm") version "1.9.21"
id("org.openjfx.javafxplugin") version "0.1.0"
id("com.github.johnrengelman.shadow") version "7.1.2"
}
var mainClassName: String by application.mainClass
mainClassName = "com.dfsek.terra.biometool.BiomeToolLauncher"
group = "com.dfsek"
version = "0.4.8"
val runDir = file("$buildDir/run")
repositories {
mavenCentral()
maven {
name = "CodeMC"
url = uri("https://repo.codemc.org/repository/maven-public/")
}
maven {
name = "Jitpack"
url = uri("https://jitpack.io")
}
}
java {
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
}
val javafxModules = listOf(
"base",
"controls",
// "fxml",
"graphics",
"media",
// "swing",
// "web",
)
javafx {
version = "17.0.9"
modules = javafxModules.map { "javafx.$it" }
}
val shadow: Configuration by configurations.getting
val compileOnly: Configuration by configurations.compileOnly
val compileClasspath: Configuration by configurations.compileClasspath
val implementation: Configuration by configurations.implementation
val runtimeClasspath: Configuration by configurations.runtimeClasspath
val linuxImplementation: Configuration by configurations.creating {
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named<Usage>(Usage.JAVA_RUNTIME))
attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, objects.named<OperatingSystemFamily>("linux"))
attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, objects.named<MachineArchitecture>("x86-64"))
}
extendsFrom(implementation)
}
val windowsImplementation: Configuration by configurations.creating {
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named<Usage>(Usage.JAVA_RUNTIME))
attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, objects.named<OperatingSystemFamily>("windows"))
attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, objects.named<MachineArchitecture>("x86-64"))
}
extendsFrom(implementation)
}
val osxImplementation: Configuration by configurations.creating {
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named<Usage>(Usage.JAVA_RUNTIME))
attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, objects.named<OperatingSystemFamily>("mac"))
attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, objects.named<MachineArchitecture>("x86-64"))
}
extendsFrom(implementation)
}
compileClasspath.extendsFrom(linuxImplementation)
compileClasspath.extendsFrom(windowsImplementation)
compileClasspath.extendsFrom(osxImplementation)
val terraAddon: Configuration by configurations.creating {
runtimeClasspath.extendsFrom(this)
}
val bootstrapTerraAddon: Configuration by configurations.creating {
runtimeClasspath.extendsFrom(this)
}
dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))
val terraGitHash = "3aef97738"
bootstrapTerraAddon("com.dfsek.terra:api-addon-loader:0.1.0-BETA+$terraGitHash")
bootstrapTerraAddon("com.dfsek.terra:manifest-addon-loader:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:biome-provider-extrusion:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:biome-provider-image:1.0.1-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:biome-provider-image:v2-1.0.1-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:biome-provider-pipeline:1.0.2-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:biome-provider-pipeline:v2-1.0.1-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:biome-provider-single:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:biome-query-api:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:chunk-generator-noise-3d:1.2.1-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:command-addons:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:command-packs:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:command-profiler:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:command-structures:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:config-biome:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:config-distributors:1.0.1-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:config-feature:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:config-flora:1.0.1-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:config-locators:1.1.1-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:config-noise-function:1.1.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:config-number-predicate:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:config-ore:1.1.1-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:config-palette:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:config-structure:1.0.1-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:generation-stage-feature:1.1.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:generation-stage-structure:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:language-yaml:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:library-image:1.1.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:locator-slant-noise-3d:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:palette-block-shortcut:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:pipeline-image:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:structure-block-shortcut:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:structure-mutator:0.1.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:structure-sponge-loader:1.0.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:structure-terrascript-loader:1.2.0-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:terrascript-function-check-noise-3d:1.0.1-BETA+$terraGitHash")
terraAddon("com.dfsek.terra:terrascript-function-sampler:1.0.0-BETA+$terraGitHash")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
implementation("com.dfsek.terra:base:6.4.1-BETA+$terraGitHash")
implementation("ca.solo-studios:slf4k:0.5.3")
implementation("ch.qos.logback:logback-classic:1.4.14")
implementation("com.google.guava:guava:32.1.3-jre")
implementation("no.tornado:tornadofx:1.7.20") {
exclude("org.jetbrains.kotlin")
}
implementation("commons-io:commons-io:2.15.1")
for (javafxModule in javafxModules) {
val mavenCoordinates = "org.openjfx:javafx-$javafxModule:${javafx.version}"
linuxImplementation("$mavenCoordinates:linux")
windowsImplementation("$mavenCoordinates:win")
osxImplementation("$mavenCoordinates:mac")
}
// Jansi for terminal colouring on Windows
windowsImplementation("org.fusesource.jansi:jansi:2.4.1")
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "17"
}
val jar by tasks.jar
val javadoc by tasks.javadoc
tasks.withType<ShadowJar>() {
if (name == ShadowJavaPlugin.SHADOW_JAR_TASK_NAME)
return@withType
group = "Jar"
description = "A platform jar for $archiveClassifier with runtime dependencies"
manifest.inheritFrom(jar.manifest)
from(sourceSets.main.orNull?.output)
configurations.add(project.configurations.runtimeClasspath.orNull)
exclude("META-INF/INDEX.LIST", "META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA", "module-info.class")
tasks.register<ConfigureShadowRelocation>(
ConfigureShadowRelocation.taskName(this)
) {
[email protected](this)
}
doFirst {
archiveVersion.set(project.version.toString())
}
}
val javadocJar by tasks.creating(Jar::class) {
archiveClassifier.set("javadoc")
dependsOn(javadoc)
from(javadoc.destinationDir)
}
val sourcesJar by tasks.creating(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}
val shadowJarLinux by tasks.creating(ShadowJar::class) {
archiveClassifier.set("linux")
configurations = listOf(linuxImplementation)
}
val shadowJarWin by tasks.creating(ShadowJar::class) {
archiveClassifier.set("win")
configurations = listOf(windowsImplementation)
}
val shadowJarOSX by tasks.creating(ShadowJar::class) {
archiveClassifier.set("osx")
configurations = listOf(osxImplementation)
}
val shadowJarAll by tasks.creating(ShadowJar::class) {
archiveClassifier.set("all")
configurations = listOf(linuxImplementation, windowsImplementation, osxImplementation)
}
tasks.named("shadowDistZip") {
dependsOn(shadowJarAll)
}
tasks.named("shadowDistTar") {
dependsOn(shadowJarAll)
}
tasks.named("startShadowScripts") {
dependsOn(shadowJarAll)
}
tasks.withType<Jar>() {
entryCompression = ZipEntryCompression.STORED
manifest {
attributes(
"Main-Class" to mainClassName,
"Built-By" to System.getProperties()["user.name"],
"Built-Jdk" to System.getProperties()["java.version"],
"Name" to project.name,
"Add-Opens" to "javafx.graphics/javafx.scene",
)
}
}
val downloadDefaultPacks: Task by tasks.creating() {
group = "application"
doFirst {
val defaultPack = URL("https://github.com/PolyhedralDev/TerraOverworldConfig/releases/download/latest/default.zip")
val fileName = defaultPack.file.substring(defaultPack.file.lastIndexOf("/"))
file("$runDir/packs/").mkdirs()
defaultPack.openStream().transferTo(file("$runDir/packs/$fileName").outputStream())
}
}
val prepareRunAddons by tasks.creating(Sync::class) {
group = "application"
val terraAddonJars = terraAddon.resolvedConfiguration.firstLevelModuleDependencies.flatMap { dependency ->
dependency.moduleArtifacts.map { it.file }
}
val terraBoostrapJars = bootstrapTerraAddon.resolvedConfiguration.firstLevelModuleDependencies.flatMap { dependency ->
dependency.moduleArtifacts.map { it.file }
}
from(terraAddonJars)
from(terraBoostrapJars) {
into("bootstrap")
}
into("$runDir/addons")
}
tasks.getByName<JavaExec>("run") {
dependsOn(prepareRunAddons, downloadDefaultPacks)
runDir.mkdirs()
workingDir = runDir
@Suppress("UselessCallOnNotNull") // Thanks Kotlin
jvmArgs = jvmArgs.orEmpty() + listOf("--add-opens=javafx.graphics/javafx.scene=ALL-UNNAMED")
}
tasks.build {
dependsOn(javadocJar, sourcesJar)
dependsOn(project.tasks.withType<ShadowJar>())
}