-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathstonecutter.gradle.kts
More file actions
160 lines (129 loc) · 5.45 KB
/
stonecutter.gradle.kts
File metadata and controls
160 lines (129 loc) · 5.45 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import dev.kikugie.stonecutter.build.StonecutterBuildExtension
import net.fabricmc.loom.api.LoomGradleExtensionAPI
import net.fabricmc.loom.task.RemapJarTask
import org.jetbrains.kotlin.gradle.dsl.KotlinBaseExtension
plugins {
id("idea")
id("dev.kikugie.stonecutter")
// Architectury Loom was becoming annoying.
id("fabric-loom") apply false
// id("net.minecraftforge.gradle") version "[6.0,6.2)" apply false
id("net.neoforged.moddev") version "2.0.134" apply false
kotlin("jvm") version "2.3.0" apply false
kotlin("plugin.serialization") version "2.3.0" apply false
id("com.gradleup.shadow") version "9.3.0" apply false
id("me.modmuss50.mod-publish-plugin") version "0.7.+" apply false
}
stonecutter active "1.20.1"
allprojects {
group = mod.group
repositories {
mavenCentral()
maven("https://maven.parchmentmc.org")
maven("https://oss.sonatype.org/content/repositories/snapshots")
exclusiveContent {
forRepository {
maven("https://api.modrinth.com/maven")
}
filter {
includeGroup("maven.modrinth")
}
}
maven("https://repo.clojars.org")
maven("https://maven.shedaniel.me/")
maven("https://maven.terraformersmc.com/")
maven("https://maven.architectury.dev/")
maven("https://maven.maxhenkel.de/repository/public")
maven("https://maven.neoforged.net/releases/")
maven("https://maven.nucleoid.xyz/")
maven("https://maven.minecraftforge.net")
maven("https://maven.fabricmc.net")
maven("https://repo.plo.su")
maven("https://repo.plasmoverse.com/releases")
maven("https://repo.plasmoverse.com/snapshots")
maven("https://repo.nyon.dev/releases")
maven("https://mvn.devos.one/releases")
maven("https://mvn.devos.one/snapshots")
}
if (project.extensions.findByType<StonecutterBuildExtension>() == null)
return@allprojects
val sc = project.extensions.getByType<StonecutterBuildExtension>()
val common = sc.node.sibling("")
apply(plugin = "idea")
apply(plugin = "java")
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "com.gradleup.shadow")
val minecraftVersion = sc.current.version
val loader = try { project.property("loom.platform") as? String? } catch (_: Throwable) { null } ?: "unknown"
project.extensions.configure<BasePluginExtension>("base") {
archivesName.set(mod.name)
}
version = "${mod.version}+$minecraftVersion-$loader"
sc.constants.match(
loader,
"fabric", "forge", "neoforge", "unknown"
)
sc.constants["forge_like"] = loader == "forge" || loader == "neoforge"
fun loaderDep(dep: String): Any {
return common?.project?.mod?.dep(dep) ?: mod.dep(dep, "[UNSUPPORTED]")
}
dependencies {
"implementation"("org.java-websocket:Java-WebSocket:${loaderDep("java_websocket")}") {
exclude("org.slf4j", "slf4j-api")
}
"implementation"("com.squareup.okhttp3:okhttp:${loaderDep("okhttp")}") {
exclude("kotlin")
exclude("org.jetbrains")
}
"implementation"("xyz.bluspring.unitytranslate:UnityTranslateLib:${loaderDep("unitytranslatelib")}")
"implementation"("xyz.bluspring.unitytranslate:UnityTranslateLib-natives-windows-amd64:${loaderDep("unitytranslatelib")}")
"implementation"("xyz.bluspring.unitytranslate:UnityTranslateLib-natives-linux-amd64:${loaderDep("unitytranslatelib")}")
"implementation"("com.github.jnr:jnr-ffi:${loaderDep("jnr")}")
"implementation"("xyz.bluspring.modernnetworking:modernnetworking-api:${loaderDep("modernnetworking")}")!!
}
project.extensions.configure<KotlinBaseExtension>("kotlin") {
jvmToolchain(
if (sc.eval(minecraftVersion, ">=1.20.5"))
21
else 17
)
}
project.extensions.configure<JavaPluginExtension>("java") {
val java = if (sc.eval(minecraftVersion, ">=1.20.5"))
JavaVersion.VERSION_21 else JavaVersion.VERSION_17
targetCompatibility = java
sourceCompatibility = java
}
tasks.named<Jar>("jar") {
archiveClassifier = "dev"
}
tasks.named<ShadowJar>("shadowJar") {
mergeServiceFiles()
val shadowPackage = "${mod.group}.${mod.id}.shaded"
exclude("org/jetbrains/**/*", "org/intellij/**/*", "org/slf4j/**/*", "kotlin/**/*", "kotlinx/**/*")
relocate("com.mayakapps.kache", "$shadowPackage.kache")
if (loader.contains("forge")) {
relocate("org.java_websocket", "$shadowPackage.java_websocket")
relocate("okhttp3", "$shadowPackage.okhttp3")
relocate("jnr", "$shadowPackage.jnr")
}
}
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
idea {
module {
isDownloadSources = true
isDownloadJavadoc = true
}
}
}
// Runs active versions for each loader
for (it in stonecutter.tree.nodes) {
if (it.metadata != stonecutter.current || it.branch.id.isEmpty()) continue
val types = listOf("Client", "Server")
val loader = it.branch.id.upperCaseFirst()
for (type in types) it.project.tasks.register("runActive$type$loader") {
group = "project"
dependsOn("run$type")
}
}