Merge pull request #522 from EngineHub/feat/nested-fabric-api

Bundle required fabric api jars.
This commit is contained in:
wizjany 2019-09-28 19:58:52 -04:00 committed by GitHub
commit a515ed0a30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 36 deletions

View File

@ -1,3 +1,5 @@
import java.util.Properties
plugins { plugins {
`kotlin-dsl` `kotlin-dsl`
kotlin("jvm") version embeddedKotlinVersion kotlin("jvm") version embeddedKotlinVersion
@ -10,6 +12,14 @@ repositories {
name = "Forge Maven" name = "Forge Maven"
url = uri("https://files.minecraftforge.net/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 { 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 { dependencies {
implementation(gradleApi()) implementation(gradleApi())
implementation("gradle.plugin.net.minecrell:licenser:0.4.1") 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("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7")
implementation("gradle.plugin.org.spongepowered:spongegradle:0.9.0") implementation("gradle.plugin.org.spongepowered:spongegradle:0.9.0")
implementation("net.minecraftforge.gradle:ForgeGradle:3.0.143") implementation("net.minecraftforge.gradle:ForgeGradle:3.0.143")
implementation("net.fabricmc:fabric-loom:$loomVersion")
implementation("net.fabricmc:sponge-mixin:$mixinVersion")
} }

View File

@ -1,3 +1,5 @@
import org.gradle.api.Project
object Versions { object Versions {
const val TEXT = "3.0.1" const val TEXT = "3.0.1"
const val TEXT_EXTRAS = "3.0.2" const val TEXT_EXTRAS = "3.0.2"
@ -6,3 +8,12 @@ object Versions {
const val JUNIT = "5.5.0" const val JUNIT = "5.5.0"
const val MOCKITO = "3.0.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)

View File

@ -2,3 +2,6 @@ group=com.sk89q.worldedit
version=7.1.0-SNAPSHOT version=7.1.0-SNAPSHOT
org.gradle.jvmargs=-Xmx1G org.gradle.jvmargs=-Xmx1G
loom.version=0.2.5-20190906.190953-30
mixin.version=0.7.11.38

View File

@ -1,25 +1,5 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import net.fabricmc.loom.task.RemapJarTask 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() applyPlatformAndCoreConfiguration()
applyShadowConfiguration() applyShadowConfiguration()
@ -27,9 +7,8 @@ applyShadowConfiguration()
apply(plugin = "fabric-loom") apply(plugin = "fabric-loom")
val minecraftVersion = "1.14.4" val minecraftVersion = "1.14.4"
val fabricVersion = "0.3.0+build.200" val yarnMappings = "1.14.4+build.12"
val yarnMappings = "1.14.4+build.1" val loaderVersion = "0.6.2+build.166"
val loaderVersion = "0.4.8+build.155"
configurations.all { configurations.all {
resolutionStrategy { resolutionStrategy {
@ -45,7 +24,20 @@ dependencies {
"mappings"("net.fabricmc:yarn:$yarnMappings") "mappings"("net.fabricmc:yarn:$yarnMappings")
"modCompile"("net.fabricmc:fabric-loader:$loaderVersion") "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") "testCompile"("org.mockito:mockito-core:1.9.0-rc1")
} }
@ -96,16 +88,12 @@ artifacts {
add("archives", tasks.named("deobfJar")) add("archives", tasks.named("deobfJar"))
} }
// intellij has trouble detecting RemapJarTask as a subclass of Task tasks.register<RemapJarTask>("remapShadowJar") {
@Suppress("UNCHECKED_CAST") val shadowJar = tasks.getByName<ShadowJar>("shadowJar")
val remapJarIntellijHack = RemapJarTask::class as KClass<Task> dependsOn(shadowJar)
tasks.register("remapShadowJar", remapJarIntellijHack) { input.set(shadowJar.archiveFile)
(this as RemapJarTask).run { archiveFileName.set(shadowJar.archiveFileName.get().replace(Regex("-dev\\.jar$"), ".jar"))
val shadowJar = tasks.getByName<ShadowJar>("shadowJar") addNestedDependencies.set(true)
dependsOn(shadowJar)
setInput(shadowJar.archiveFile)
setOutput(shadowJar.archiveFile.get().asFile.absolutePath.replace(Regex("-dev\\.jar$"), ".jar"))
}
} }
tasks.named("assemble").configure { tasks.named("assemble").configure {

View File

@ -29,9 +29,12 @@
"depends": { "depends": {
"fabricloader": ">=0.4.0", "fabricloader": ">=0.4.0",
"fabric": "*" "fabric-api-base": "*",
"fabric-events-lifecycle-v0": "*",
"fabric-events-interaction-v0": "*",
"fabric-networking-v0": "*"
}, },
"mixins": [ "mixins": [
"worldedit.mixins.json" "worldedit.mixins.json"
] ]
} }