From 95640fe44f6bbaffaa904b148ff5829cb2b67758 Mon Sep 17 00:00:00 2001 From: Octavia Togami Date: Thu, 10 Sep 2020 16:14:09 -0700 Subject: [PATCH] [Fabric, Forge] Update build files for 1.16.3 No actual changes, beta 4 is functional, but this was to ensure it compiled. --- worldedit-fabric/build.gradle.kts | 100 +++++++++++++++++++++++------- worldedit-forge/build.gradle.kts | 4 +- 2 files changed, 81 insertions(+), 23 deletions(-) diff --git a/worldedit-fabric/build.gradle.kts b/worldedit-fabric/build.gradle.kts index 0a4cff4e6..1bbd0b436 100644 --- a/worldedit-fabric/build.gradle.kts +++ b/worldedit-fabric/build.gradle.kts @@ -1,15 +1,33 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import net.fabricmc.loom.LoomGradleExtension import net.fabricmc.loom.task.RemapJarTask +buildscript { + repositories { + mavenCentral() + maven { + name = "Fabric" + url = uri("https://maven.fabricmc.net/") + } + } + dependencies { + classpath("net.fabricmc:fabric-loom:${versions.loom}") + } +} + applyPlatformAndCoreConfiguration() applyShadowConfiguration() apply(plugin = "fabric-loom") apply(plugin = "java-library") -val minecraftVersion = "1.15.2" -val yarnMappings = "1.15.2+build.14:v2" -val loaderVersion = "0.7.8+build.189" +configure { + accessWidener("src/main/resources/worldedit.accesswidener") +} + +val minecraftVersion = "1.16.3" +val yarnMappings = "1.16.3+build.1:v2" +val loaderVersion = "0.9.3+build.207" configurations.all { resolutionStrategy { @@ -17,30 +35,74 @@ configurations.all { } } +val fabricApiConfiguration: Configuration = configurations.create("fabricApi") + +repositories { + maven { + name = "Fabric" + url = uri("https://maven.fabricmc.net/") + } +} + dependencies { - "compile"(project(":worldedit-core")) - "compile"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1") + "api"(project(":worldedit-core")) + "implementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1") "minecraft"("com.mojang:minecraft:$minecraftVersion") "mappings"("net.fabricmc:yarn:$yarnMappings") - "modCompile"("net.fabricmc:fabric-loader:$loaderVersion") + "modImplementation"("net.fabricmc:fabric-loader:$loaderVersion") - listOf( - "net.fabricmc.fabric-api:fabric-api-base:0.1.2+28f8190f42", - "net.fabricmc.fabric-api:fabric-events-interaction-v0:0.2.6+12515ed975", - "net.fabricmc.fabric-api:fabric-events-lifecycle-v0:0.1.2+b7f9825de8", - "net.fabricmc.fabric-api:fabric-networking-v0:0.1.7+12515ed975" - ).forEach { + // [1] declare fabric-api dependency... + "fabricApi"("net.fabricmc.fabric-api:fabric-api:0.20.2+build.402-1.16") + + // [2] Load the API dependencies from the fabric mod json... + @Suppress("UNCHECKED_CAST") + val fabricModJson = file("src/main/resources/fabric.mod.json").bufferedReader().use { + groovy.json.JsonSlurper().parse(it) as Map> + } + val wantedDependencies = (fabricModJson["depends"] ?: error("no depends in fabric.mod.json")).keys + .filter { it == "fabric-api-base" || it.contains(Regex("v\\d$")) } + .map { "net.fabricmc.fabric-api:$it" } + logger.lifecycle("Looking for these dependencies:") + for (wantedDependency in wantedDependencies) { + logger.lifecycle(wantedDependency) + } + // [3] and now we resolve it to pick out what we want :D + val fabricApiDependencies = fabricApiConfiguration.incoming.resolutionResult.allDependencies + .onEach { + if (it is UnresolvedDependencyResult) { + throw kotlin.IllegalStateException("Failed to resolve Fabric API", it.failure) + } + } + .filterIsInstance() + // pick out transitive dependencies + .flatMap { + it.selected.dependencies + } + // grab the requested versions + .map { it.requested } + .filterIsInstance() + // map to standard notation + .associateByTo( + mutableMapOf(), + keySelector = { "${it.group}:${it.module}" }, + valueTransform = { "${it.group}:${it.module}:${it.version}" } + ) + fabricApiDependencies.keys.retainAll(wantedDependencies) + // sanity check + for (wantedDep in wantedDependencies) { + check(wantedDep in fabricApiDependencies) { "Fabric API library $wantedDep is missing!" } + } + + fabricApiDependencies.values.forEach { "include"(it) "modImplementation"(it) } // Hook these up manually, because Fabric doesn't seem to quite do it properly. - "compileClasspath"("net.fabricmc:sponge-mixin:${project.versions.mixin}") + "compileOnly"("net.fabricmc:sponge-mixin:${project.versions.mixin}") "annotationProcessor"("net.fabricmc:sponge-mixin:${project.versions.mixin}") "annotationProcessor"("net.fabricmc:fabric-loom:${project.versions.loom}") - - "testCompile"("org.mockito:mockito-core:1.9.0-rc1") } configure { @@ -62,12 +124,7 @@ tasks.named("processResources") { } } -tasks.named("jar") { - manifest { - attributes("Class-Path" to CLASSPATH, - "WorldEdit-Version" to project.version) - } -} +addJarManifest(includeClasspath = true) tasks.named("shadowJar") { archiveClassifier.set("dist-dev") @@ -97,6 +154,7 @@ tasks.register("remapShadowJar") { input.set(shadowJar.archiveFile) archiveFileName.set(shadowJar.archiveFileName.get().replace(Regex("-dev\\.jar$"), ".jar")) addNestedDependencies.set(true) + remapAccessWidener.set(true) } tasks.named("assemble").configure { diff --git a/worldedit-forge/build.gradle.kts b/worldedit-forge/build.gradle.kts index df6f8d21f..5df186510 100644 --- a/worldedit-forge/build.gradle.kts +++ b/worldedit-forge/build.gradle.kts @@ -12,12 +12,12 @@ plugins { applyPlatformAndCoreConfiguration() applyShadowConfiguration() -val minecraftVersion = "1.16.2" +val minecraftVersion = "1.16.3" val nextMajorMinecraftVersion: String = minecraftVersion.split('.').let { (useless, major) -> "$useless.${major.toInt() + 1}" } val mappingsMinecraftVersion = "1.16" -val forgeVersion = "32.0.92" +val forgeVersion = "34.0.0" configurations.all { resolutionStrategy {