-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
211 lines (187 loc) · 6.24 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import net.fabricmc.loom.api.LoomGradleExtensionAPI
import net.fabricmc.loom.task.RemapJarTask
plugins {
`java-library`
`maven-publish`
alias(libs.plugins.architectury.plugin)
alias(libs.plugins.architectury.loom).apply(false)
alias(libs.plugins.shadow).apply(false)
}
val minecraftVersion: String by rootProject
val enabledPlatforms: String by rootProject
val fabricLoaderVersion: String by rootProject
val architecturyVersion: String by rootProject
val fabricApiVersion: String by rootProject
architectury {
minecraft = minecraftVersion
}
val archivesName: String by rootProject
val modVersion: String by rootProject
val mavenGroup: String by rootProject
allprojects {
apply(plugin = "java-library")
apply(plugin = "architectury-plugin")
apply(plugin = "maven-publish")
base.archivesName = archivesName
version = modVersion
group = mavenGroup
repositories {
maven {
name = "fabric MC"
url = uri("https://maven.fabricmc.net/")
}
maven {
name = "architectury"
url = uri("https://maven.architectury.dev/")
}
maven {
name = "forge"
url = uri("https://maven.minecraftforge.net/")
}
maven {
name = "parchment maven"
url = uri("https://maven.parchmentmc.org/")
}
}
tasks {
withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(21)
}
java {
withSourcesJar()
}
processResources {
inputs.property("version", project.version);
filesMatching(listOf("META-INF/mods.toml", "fabric.mods.toml")) {
expand("version" to project.version)
}
}
}
}
subprojects {
apply(plugin = "maven-publish")
apply(plugin = "dev.architectury.loom")
apply(plugin = "architectury-plugin")
apply(plugin = "com.github.johnrengelman.shadow")
configure<LoomGradleExtensionAPI> {
silentMojangMappingsLicense()
}
architectury {
when(project.name) {
"common" -> {
common(enabledPlatforms.split(","))
}
"fabric" -> {
platformSetupLoomIde()
fabric()
}
"forge" -> {
platformSetupLoomIde()
forge()
}
"neoforge" -> {
neoForge {
platformPackage = "forge"
}
}
}
}
if (project.name != "common") {
val common by configurations.creating
val shadowCommon by configurations.creating
val developmentFabric by configurations.getting
configurations {
compileClasspath.configure { extendsFrom(common) }
runtimeClasspath.configure { extendsFrom(common) }
developmentFabric.extendsFrom(common)
}
}
dependencies {
val minecraft by configurations.getting
val mappings by configurations.getting
val modImplementation by configurations.getting
val modApi by configurations.getting
minecraft("com.mojang:minecraft:${minecraftVersion}")
mappings(project.the<LoomGradleExtensionAPI>().layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${minecraftVersion}:2024.06.23@zip")
})
if (!project.name.contains("forge")) {
modImplementation("net.fabricmc:fabric-loader:${fabricLoaderVersion}")
}
modApi("dev.architectury:architectury${if (project.name == "common") "" else "-${project.name}"}:${architecturyVersion}")
when(project.name) {
"fabric" -> {
modApi("net.fabricmc.fabric-api:fabric-api:${fabricApiVersion}")
}
}
if (project.name != "common") {
val common by configurations.getting
val shadowCommon by configurations.getting
common(project(path = ":common", configuration = "namedElements")) { setTransitive(false) }
shadowCommon(project(path = ":common", configuration = "transformProductionFabric")) { setTransitive(false) }
}
}
if(project.name != "common") {
val shadowCommon by configurations.getting
tasks {
jar {
archiveClassifier.set("dev")
}
val shadowJar = named<ShadowJar>("shadowJar") {
if (project.name.contains("forge")) {
exclude("fabric.mod.json")
}
configurations = listOf(shadowCommon)
archiveClassifier.set("dev-shadow")
}
named<RemapJarTask>("remapJar") {
injectAccessWidener.set(true)
inputFile.set(shadowJar.get().archiveFile)
dependsOn(shadowJar.get())
archiveClassifier.set(null as String?)
}
named<Jar>("sourcesJar") {
val commonSourcesJar = project(":common").tasks.named<Jar>("sourcesJar").get()
dependsOn(commonSourcesJar)
from(commonSourcesJar.archiveFile.map {
zipTree(it)
})
}
}
components.getByName("java") {
this as AdhocComponentWithVariants
this.withVariantsFromConfiguration(project.configurations.getByName("shadowRuntimeElements")) {
skip()
}
}
}
publishing {
publications {
create<MavenPublication>("${project.name}Maven") {
artifactId = "${archivesName}-${project.name}-${minecraftVersion}"
from(components["java"])
}
}
}
sourceSets {
main {
java {
setSrcDirs(setOf(rootProject.file("src/${project.name}/java")))
}
resources {
setSrcDirs(setOf(rootProject.file("src/${project.name}/resources")))
}
}
test {
java {
setSrcDirs(HashSet<File>())
}
resources {
setSrcDirs(HashSet<File>())
}
}
}
}