-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.gradle.kts
304 lines (268 loc) · 9.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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import me.modmuss50.mpp.ReleaseType
import net.neoforged.moddevgradle.dsl.RunModel
import java.time.LocalDateTime
plugins {
java
`maven-publish`
id("net.neoforged.moddev") version "2.0.1-beta"
id("io.github.goooler.shadow") version "8.1.8" apply false
id("me.modmuss50.mod-publish-plugin") version "0.5.+"
id("net.neoforged.gradleutils") version "3.0.0"
id("org.sinytra.adapter.userdev") version "1.2-SNAPSHOT"
}
val versionConnector: String by project
val versionAdapter: String by project
val versionAdapterDefinition: String by project
val versionAdapterRuntime: String by project
val versionMc: String by project
val versionNeoForge: String by project
val versionParchmentMc: String by project
val versionParchment: String by project
val versionForgeAutoRenamingTool: String by project
val versionForgifiedFabricLoader: String by project
val versionAccessWidener: String by project
val versionForgifiedFabricApi: String by project
val curseForgeId: String by project
val modrinthId: String by project
val githubRepository: String by project
val publishBranch: String by project
val forgifiedFabricApiCurseForge: String by project
val forgifiedFabricApiModrinth: String by project
val connectorExtrasCurseForge: String by project
val connectorExtrasModrinth: String by project
val mixinextrasVersion: String by project
val PUBLISH_RELEASE_TYPE: Provider<String> = providers.environmentVariable("PUBLISH_RELEASE_TYPE")
group = "org.sinytra"
version = "$versionConnector+$versionMc"
// Append git commit hash for dev versions
if (!PUBLISH_RELEASE_TYPE.isPresent) {
version = "$version+dev-${gradleutils.gitInfo["hash"]}"
}
logger.lifecycle("Project version: $version")
val mod: SourceSet by sourceSets.creating
val test: SourceSet by sourceSets
val shade: Configuration by configurations.creating
val adapterData: Configuration by configurations.creating
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
withSourcesJar()
}
configurations {
compileOnly {
extendsFrom(shade)
}
"modCompileOnly" {
extendsFrom(configurations.compileOnly.get())
}
"modImplementation" {
extendsFrom(shade)
}
additionalRuntimeClasspath {
extendsFrom(shade)
}
}
println("Java: ${System.getProperty("java.version")}, JVM: ${System.getProperty("java.vm.version")} (${System.getProperty("java.vendor")}), Arch: ${System.getProperty("os.arch")}")
neoForge {
// Specify the version of NeoForge to use.
version = versionNeoForge
accessTransformers {
from(project.file("src/mod/resources/META-INF/accesstransformer.cfg"))
}
parchment {
mappingsVersion = versionParchment
minecraftVersion = versionParchmentMc
}
runs {
val config = Action<RunModel> {
systemProperty("forge.logging.console.level", "debug")
systemProperty("forge.logging.markers", "REGISTRIES,SCAN,FMLHANDSHAKE,COREMOD")
systemProperty("connector.logging.markers", "MIXINPATCH,MERGER")
systemProperty("mixin.debug.export", "true")
gameDirectory.set(layout.projectDirectory.dir("run"))
mods {
maybeCreate("connector").apply {
sourceSet(mod)
}
}
}
create("client") {
client()
config(this)
}
create("server") {
server()
config(this)
}
}
}
repositories {
maven {
name = "Sinytra"
url = uri("https://maven.su5ed.dev/releases")
content {
includeGroupAndSubgroups("org.sinytra")
}
}
maven {
url = uri("https://www.cursemaven.com")
content {
includeGroup("curse.maven")
}
}
}
dependencies {
shade(group = "org.sinytra", name = "forgified-fabric-loader", version = versionForgifiedFabricLoader)
shade(group = "net.fabricmc", name = "access-widener", version = versionAccessWidener) { isTransitive = false }
shade(group = "org.sinytra", name = "ForgeAutoRenamingTool", version = versionForgeAutoRenamingTool) { isTransitive = false }
shade(group = "org.sinytra.adapter", name = "definition", version = versionAdapterDefinition) { isTransitive = false }
adapterData(group = "org.sinytra.adapter", name = "adapter", version = versionAdapter)
jarJar(implementation(group = "org.sinytra.adapter", name = "runtime", version = versionAdapterRuntime))
"modImplementation"(implementation(group = "org.sinytra.forgified-fabric-api", name = "forgified-fabric-api", version = versionForgifiedFabricApi)) {
exclude(group = "org.sinytra", module = "forgified-fabric-loader")
}
"modCompileOnly"(sourceSets.main.get().output)
additionalRuntimeClasspath(files(tasks.jar))
implementation("curse.maven:connector-extras-913445:5618470")
}
val modJar: Jar by tasks.creating(Jar::class) {
from(mod.output)
manifest.attributes("Implementation-Version" to project.version)
archiveClassifier.set("mod")
}
localJarJar("modJarConfig", "org.sinytra:connector-mod", project.version.toString(), modJar)
val depsJar: ShadowJar by tasks.creating(ShadowJar::class) {
configurations = listOf(shade)
exclude(
"assets/fabricloader/**",
"META-INF/*.SF", "META-INF/*.RSA",
"META-INF/maven/**", "META-INF/jars/**", "META-INF/jarjar/**"
)
exclude("META-INF/services/net.neoforged.neoforgespi.language.IModLanguageLoader")
exclude("ui/**")
exclude("*.json", "*.html", "*.version")
exclude("module-info.class")
exclude("LICENSE.txt")
dependencies {
exclude(dependency("org.ow2.asm:"))
exclude(dependency("net.sf.jopt-simple:"))
exclude(dependency("com.google.guava:guava"))
exclude(dependency("com.google.code.gson:gson"))
}
archiveClassifier.set("deps")
}
val fullJar by tasks.registering(ShadowJar::class) {
from(tasks.jar, depsJar)
mergeServiceFiles() // Relocate services
relocate("net.minecraftforge.fart", "reloc.net.minecraftforge.fart")
relocate("net.minecraftforge.srgutils", "reloc.net.minecraftforge.srgutils")
relocate("net.fabricmc.accesswidener", "reloc.net.fabricmc.accesswidener")
relocate("org.sat4j", "reloc.org.sat4j")
relocate("net.bytebuddy", "reloc.net.bytebuddy")
manifest.attributes(tasks.jar.get().manifest.attributes)
archiveClassifier.set("full")
}
tasks {
jar {
from(zipTree(provider { adapterData.singleFile })) {
into("adapter_data")
include("*.json")
}
manifest {
attributes(
"Specification-Title" to project.name,
"Specification-Vendor" to "Sinytra",
"Specification-Version" to "1",
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to "Sinytra",
"Implementation-Timestamp" to LocalDateTime.now(),
"Automatic-Module-Name" to "org.sinytra.connector",
"Fabric-Loader-Version" to versionForgifiedFabricLoader.split("+")[1]
)
}
}
withType<JavaCompile> {
options.encoding = "UTF-8"
}
assemble {
dependsOn(fullJar)
}
}
publishMods {
file.set(fullJar.flatMap { it.archiveFile })
changelog.set(providers.environmentVariable("CHANGELOG").orElse("# $version"))
type.set(PUBLISH_RELEASE_TYPE.orElse("alpha").map(ReleaseType::of))
modLoaders.add("neoforge")
dryRun.set(!providers.environmentVariable("CI").isPresent)
github {
accessToken.set(providers.environmentVariable("GITHUB_TOKEN"))
repository.set(githubRepository)
commitish.set(publishBranch)
}
curseforge {
accessToken.set(providers.environmentVariable("CURSEFORGE_TOKEN"))
projectId.set(curseForgeId)
minecraftVersions.add(versionMc)
requires {
slug.set(forgifiedFabricApiCurseForge)
}
optional {
slug.set(connectorExtrasCurseForge)
}
}
modrinth {
accessToken.set(providers.environmentVariable("MODRINTH_TOKEN"))
projectId.set(modrinthId)
minecraftVersions.add(versionMc)
requires {
id.set(forgifiedFabricApiModrinth)
}
optional {
id.set(connectorExtrasModrinth)
}
}
}
configurations.runtimeElements {
setExtendsFrom(emptySet())
outgoing {
artifacts.clear()
artifact(fullJar)
}
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
suppressAllPomMetadataWarnings()
from(components["java"])
}
}
repositories {
val env = System.getenv()
if (env["MAVEN_URL"] != null) {
repositories.maven {
url = uri(env["MAVEN_URL"] as String)
if (env["MAVEN_USERNAME"] != null) {
credentials {
username = env["MAVEN_USERNAME"]
password = env["MAVEN_PASSWORD"]
}
}
}
}
}
}
fun localJarJar(configName: String, mavenCoords: String, version: String, artifact: Any) {
configurations.create(configName) {
attributes {
attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_RUNTIME))
}
outgoing {
artifact(artifact)
capability("$mavenCoords:$version")
}
}
dependencies {
jarJar(project(":")) { capabilities { requireCapability(mavenCoords) } }
}
}