-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
190 lines (156 loc) · 6.28 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
@file:Suppress("UNCHECKED_CAST")
import net.fabricmc.loom.api.LoomGradleExtensionAPI
val minecraftVersion: String by project
val modName: String by project
val modAuthor: String by project
val parchmentVersion: String by project
val modId: String by project
val modGroup: String by project
val releaseType: String by project
val imguiVersion: String by project
val kotlinVersion: String by project
val javaVersion: String by project
val modVersion = rootProject.file("VERSION").readText().trim()
val relId = when(releaseType) {
"alpha" -> releaseType
"beta" -> releaseType
"snapshot" -> releaseType
else -> ""
}
println("Mod Version: $modVersion") // Debug
plugins {
java
`maven-publish`
id("architectury-plugin") version "3.4-SNAPSHOT"
id("dev.architectury.loom") version "1.6-SNAPSHOT" apply false
id("com.modrinth.minotaur") version "2.+"
kotlin("jvm")
kotlin("plugin.serialization")
}
architectury {
minecraft = minecraftVersion
}
subprojects {
apply(plugin = "architectury-plugin")
apply(plugin = "dev.architectury.loom")
val loom: LoomGradleExtensionAPI = project.extensions.getByName<LoomGradleExtensionAPI>("loom")
loom.apply {
silentMojangMappingsLicense()
val fileAW = project(":common").file("src/main/resources/$modId.accesswidener")
if (fileAW.exists()) accessWidenerPath.set(fileAW)
}
extensions.configure<JavaPluginExtension> {
toolchain.languageVersion.set(JavaLanguageVersion.of(javaVersion))
withSourcesJar()
}
repositories {
mavenCentral()
maven("https://maven.parchmentmc.org")
maven("https://repo.spongepowered.org/repository/maven-public/")
maven("https://maven.blamejared.com")
maven("https://thedarkcolour.github.io/KotlinForForge/")
maven("https://maven.shedaniel.me/")
maven("https://maven.architectury.dev/")
maven("https://maven.terraformersmc.com/releases/")
maven("https://jitpack.io")
maven("https://maven.0mods.team/releases")
maven("https://plugins.gradle.org/m2/")
maven("https://maven.fabricmc.net/")
maven("https://maven.neoforged.net/releases")
maven("https://maven.minecraftforge.net")
flatDir {
dirs("libs")
}
}
dependencies {
"minecraft"("com.mojang:minecraft:$minecraftVersion")
@Suppress("UnstableApiUsage")
"mappings"(loom.layered {
this.officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${minecraftVersion}:${parchmentVersion}@zip")
})
if (project != findProject(":common")) {
if (project != findProject(":forge") && project != findProject(":neoforge")) "include"("team.0mods:KotlinExtras:1.3")
else "include"("thedarkcolour:kotlinforforge:5.3.0")
"include"("io.github.classgraph:classgraph:4.8.173")
}
}
tasks.processResources {
val modLoader: String by project; val mlVersion: String by project; val license: String by project
val credits: String by project; val modAuthor: String by project; val mcRange: String by project
val modName: String by project; val modId: String by project; val description: String by project
val fabricLoaderVersion: String by project
val forgeVersionRange: String by project; val neoVersionRange: String by project
val replacement = mapOf(
"modloader" to modLoader, "mlVersion" to mlVersion, "license" to license, "modId" to modId,
"modVersion" to modVersion, "modName" to modName, "credits" to credits,"modAuthor" to modAuthor,
"description" to description, "mcRange" to mcRange,
"fabricLoaderVersion" to fabricLoaderVersion,
"minecraftVersion" to minecraftVersion, "forgeVersionRange" to forgeVersionRange,
"neoVersionRange" to neoVersionRange
)
from(project(":common").sourceSets.main.get().resources)
filesMatching(listOf("META-INF/mods.toml", "pack.mcmeta", "*.mixins.json", "fabric.mod.json")) {
expand(replacement)
}
inputs.properties(replacement)
}
tasks.withType<GenerateModuleMetadata> {
enabled = false
}
}
allprojects {
apply(plugin = "java")
apply(plugin = "kotlin")
apply(plugin = "maven-publish")
apply(plugin = "org.jetbrains.kotlin.plugin.serialization")
val archName = if (relId.isNotEmpty()) "$modName-$relId.$minecraftVersion" else "$modName.$minecraftVersion"
group = modGroup
version = modVersion
base {
archivesName.set(archName.lowercase())
}
repositories {
mavenCentral()
}
dependencies {
compileOnly("org.jetbrains:annotations:24.1.0")
//Kotlin
implementation(kotlin("reflect", kotlin.coreLibrariesVersion))
implementation(kotlin("stdlib", kotlin.coreLibrariesVersion))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:+")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:+")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:+")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:+")
//ImGui
implementation("io.github.spair:imgui-java-binding:$imguiVersion")
implementation("io.github.spair:imgui-java-lwjgl3:$imguiVersion")
implementation("io.github.spair:imgui-java-natives-windows:$imguiVersion")
implementation("io.github.spair:imgui-java-natives-linux:$imguiVersion")
implementation("io.github.spair:imgui-java-natives-macos:$imguiVersion")
// ClassGraph
implementation("io.github.classgraph:classgraph:4.8.173")
}
tasks {
jar {
from("LICENSE") {
rename { "${it}_${modName}" }
}
}
withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(javaVersion.toInt())
}
compileKotlin {
useDaemonFallbackStrategy.set(false)
compilerOptions.freeCompilerArgs.add("-Xjvm-default=all")
}
}
}
tasks.build.get().finalizedBy("mergeJars")
tasks.assemble.get().finalizedBy("mergeJars")
val String.mixin
get() = "$modId${
if (this.isNotEmpty()) ".$this"
else ""
}.mixins.json"