-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
112 lines (92 loc) · 3.57 KB
/
build.gradle.kts
File metadata and controls
112 lines (92 loc) · 3.57 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
import org.gradle.plugins.ide.idea.model.IdeaLanguageLevel
import org.jetbrains.gradle.ext.runConfigurations
import org.jetbrains.gradle.ext.settings
plugins {
id("org.jetbrains.gradle.plugin.idea-ext") version "1.3"
id("io.freefair.lombok") version "9.1.0" apply false
id("java-library")
}
allprojects {
apply(plugin = "org.jetbrains.gradle.plugin.idea-ext")
idea {
module {
excludeDirs.addAll(setOf(".gradle", ".idea", "build", "gradle", "run", "gradlew", "gradlew.bat", "desktop.ini").map(::file))
}
}
}
val jvmCommonArgs = "-Dfile.encoding=UTF-8 -XX:+UseStringDeduplication"
subprojects {
apply(plugin = "io.freefair.lombok")
apply(plugin = "java-library")
group = "dev.redstudio"
version = "0.7.1" // Versioning must follow Ragnarök versioning convention: https://github.com/Red-Studio-Ragnarok/Commons/blob/main/Ragnar%C3%B6k%20Versioning%20Convention.md
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
annotationProcessor("net.java.dev.jna:jna-platform:5.13.0")
compileOnly("com.pkware.jabel:jabel-javac-plugin:1.0.1-1") { isTransitive = false }
testAnnotationProcessor("com.pkware.jabel:jabel-javac-plugin:1.0.1-1")
testCompileOnly("com.pkware.jabel:jabel-javac-plugin:1.0.1-1") { isTransitive = false }
}
// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
vendor.set(JvmVendorSpec.ADOPTIUM)
}
withSourcesJar() // Generate sources jar
}
tasks {
withType<JavaCompile> {
options.encoding = "UTF-8"
options.compilerArgs.add("-Xlint:-options")
options.isFork = true
options.forkOptions.jvmArgs = jvmCommonArgs.split(" ")
if (name != "compileMcLauncherJava" && name != "compilePatchedMcJava" && name != "generateEffectiveLombokConfig") {
sourceCompatibility = "21"
options.release = 8
options.compilerArgs.add("--release=8")
javaCompiler.set(project.javaToolchains.compilerFor {
languageVersion.set(JavaLanguageVersion.of(21))
})
}
}
// Define embedded dependencies configuration
val implementation by configurations.getting
val embed = configurations.register("embed") {
description = "Embedded dependencies"
isTransitive = true
implementation.extendsFrom(this)
}
// Include embedded dependencies into the jar
named<Jar>("jar") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn(embed)
from(embed.map { config ->
config.map {
if (it.isDirectory) it else zipTree(it)
}
})
}
}
}
idea {
project {
settings {
jdkName = "21"
languageLevel = IdeaLanguageLevel("JDK_21")
runConfigurations {
listOf("Client", "Server", "Obfuscated Client", "Obfuscated Server", "Vanilla Client", "Vanilla Server").forEach { name ->
create(name, org.jetbrains.gradle.ext.Gradle::class.java) {
val prefix = name.substringBefore(" ").let { if (it == "Obfuscated") "Obf" else it }
val suffix = name.substringAfter(" ").takeIf { it != prefix } ?: ""
taskNames = setOf("run$prefix$suffix")
jvmArgs = jvmCommonArgs
}
}
}
}
}
}