diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 40fd86deb..1d3389b09 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,3 +1,5 @@ +import java.util.Properties + plugins { `kotlin-dsl` kotlin("jvm") version embeddedKotlinVersion @@ -10,6 +12,14 @@ repositories { name = "Forge Maven" url = uri("https://files.minecraftforge.net/maven") } + maven { + name = "Fabric" + url = uri("https://maven.fabricmc.net/") + } + maven { + name = "sponge" + url = uri("https://repo.spongepowered.org/maven") + } } configurations.all { @@ -23,6 +33,14 @@ configurations.all { } } +val properties = Properties().also { props -> + project.projectDir.resolveSibling("gradle.properties").bufferedReader().use { + props.load(it) + } +} +val loomVersion: String = properties.getProperty("loom.version") +val mixinVersion: String = properties.getProperty("mixin.version") + dependencies { implementation(gradleApi()) implementation("gradle.plugin.net.minecrell:licenser:0.4.1") @@ -33,4 +51,6 @@ dependencies { implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7") implementation("gradle.plugin.org.spongepowered:spongegradle:0.9.0") implementation("net.minecraftforge.gradle:ForgeGradle:3.0.143") + implementation("net.fabricmc:fabric-loom:$loomVersion") + implementation("net.fabricmc:sponge-mixin:$mixinVersion") } diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index b460f77eb..391029752 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -1,3 +1,5 @@ +import org.gradle.api.Project + object Versions { const val TEXT = "3.0.1" const val TEXT_EXTRAS = "3.0.2" @@ -6,3 +8,12 @@ object Versions { const val JUNIT = "5.5.0" const val MOCKITO = "3.0.0" } + +// Properties that need a project reference to resolve: +class ProjectVersions(project: Project) { + val loom = project.rootProject.property("loom.version") + val mixin = project.rootProject.property("mixin.version") +} + +val Project.versions + get() = ProjectVersions(this) diff --git a/gradle.properties b/gradle.properties index 4d41d3dcb..61c2c8bdf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,3 +2,6 @@ group=com.sk89q.worldedit version=7.1.0-SNAPSHOT org.gradle.jvmargs=-Xmx1G + +loom.version=0.2.5-20190906.190953-30 +mixin.version=0.7.11.38 diff --git a/worldedit-fabric/build.gradle.kts b/worldedit-fabric/build.gradle.kts index f8cb056eb..84d19a01e 100644 --- a/worldedit-fabric/build.gradle.kts +++ b/worldedit-fabric/build.gradle.kts @@ -1,25 +1,5 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import net.fabricmc.loom.task.RemapJarTask -import kotlin.reflect.KClass - -buildscript { - repositories { - jcenter() - maven { - name = "Fabric" - url = uri("https://maven.fabricmc.net/") - } - maven { - name = "sponge" - url = uri("https://repo.spongepowered.org/maven") - } - } - - dependencies { - "classpath"("net.fabricmc:fabric-loom:0.2.3-SNAPSHOT") - "classpath"("org.spongepowered:mixin:0.7.11-SNAPSHOT") - } -} applyPlatformAndCoreConfiguration() applyShadowConfiguration() @@ -27,9 +7,8 @@ applyShadowConfiguration() apply(plugin = "fabric-loom") val minecraftVersion = "1.14.4" -val fabricVersion = "0.3.0+build.200" -val yarnMappings = "1.14.4+build.1" -val loaderVersion = "0.4.8+build.155" +val yarnMappings = "1.14.4+build.12" +val loaderVersion = "0.6.2+build.166" configurations.all { resolutionStrategy { @@ -45,7 +24,20 @@ dependencies { "mappings"("net.fabricmc:yarn:$yarnMappings") "modCompile"("net.fabricmc:fabric-loader:$loaderVersion") - "modCompile"("net.fabricmc.fabric-api:fabric-api:$fabricVersion") + listOf( + "net.fabricmc.fabric-api:fabric-api-base:0.1.0+2983bc0442", + "net.fabricmc.fabric-api:fabric-events-interaction-v0:0.1.1+591e97ae42", + "net.fabricmc.fabric-api:fabric-events-lifecycle-v0:0.1.1+591e97ae42", + "net.fabricmc.fabric-api:fabric-networking-v0:0.1.3+591e97ae42" + ).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}") + "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") } @@ -96,16 +88,12 @@ artifacts { add("archives", tasks.named("deobfJar")) } -// intellij has trouble detecting RemapJarTask as a subclass of Task -@Suppress("UNCHECKED_CAST") -val remapJarIntellijHack = RemapJarTask::class as KClass -tasks.register("remapShadowJar", remapJarIntellijHack) { - (this as RemapJarTask).run { - val shadowJar = tasks.getByName("shadowJar") - dependsOn(shadowJar) - setInput(shadowJar.archiveFile) - setOutput(shadowJar.archiveFile.get().asFile.absolutePath.replace(Regex("-dev\\.jar$"), ".jar")) - } +tasks.register("remapShadowJar") { + val shadowJar = tasks.getByName("shadowJar") + dependsOn(shadowJar) + input.set(shadowJar.archiveFile) + archiveFileName.set(shadowJar.archiveFileName.get().replace(Regex("-dev\\.jar$"), ".jar")) + addNestedDependencies.set(true) } tasks.named("assemble").configure { diff --git a/worldedit-fabric/src/main/resources/fabric.mod.json b/worldedit-fabric/src/main/resources/fabric.mod.json index ee3e7b612..705320db0 100644 --- a/worldedit-fabric/src/main/resources/fabric.mod.json +++ b/worldedit-fabric/src/main/resources/fabric.mod.json @@ -29,9 +29,12 @@ "depends": { "fabricloader": ">=0.4.0", - "fabric": "*" + "fabric-api-base": "*", + "fabric-events-lifecycle-v0": "*", + "fabric-events-interaction-v0": "*", + "fabric-networking-v0": "*" }, "mixins": [ "worldedit.mixins.json" ] -} \ No newline at end of file +}