diff --git a/build.gradle.kts b/build.gradle.kts index 3bfba7f..3c647af 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,16 +1,14 @@ +@file:Suppress("UnstableApiUsage") + +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import xyz.wagyourtail.unimined.api.minecraft.task.RemapJarTask import xyz.wagyourtail.unimined.util.sourceSets plugins { id("java") id("xyz.wagyourtail.unimined") - id("io.github.pacifistmc.forgix") id("com.github.johnrengelman.shadow") } -try { - Git.repository = rootDir.toPath() -} catch(_: IllegalStateException) { -} setup() @@ -54,6 +52,10 @@ allprojects { options.encoding = "UTF-8" options.release = 17 options.compilerArgs.addAll(listOf("-Xplugin:Manifold no-bootstrap", "-implicit:none")) + + javaCompiler = javaToolchains.compilerFor { + languageVersion.set(JavaLanguageVersion.of(17)) + } } tasks.withType { @@ -68,6 +70,8 @@ allprojects { mojmap() parchment(version = "parchment_version"()) } + + defaultRemapJar = false } tasks.withType { @@ -82,6 +86,7 @@ allprojects { annotationProcessor(this) } compileOnly("dev.architectury:architectury-injectables:${"arch_injectables_version"()}") + compileOnly("io.github.llamalad7:mixinextras-common:${"mixin_extras_version"()}") } } @@ -107,10 +112,27 @@ subprojects { source(rootProject.sourceSets["main"].allSource) } + val common by configurations.registering { + isTransitive = false + } + dependencies { - implementation(rootProject).apply { - (this as ModuleDependency).isTransitive = false - } + common(rootProject) + } + + tasks.shadowJar { + archiveBaseName.set("archives_base_name"()) + archiveVersion.set("modVersion"()) + archiveClassifier.set(project.name) + + configurations = listOf(common.get()) + + relocate("dev.rdh.createunlimited.${project.name}", "dev.rdh.createunlimited.platform") + relocate("dev.rdh.createunlimited", "dev.rdh.createunlimited.${project.name}") + } + + unimined.minecraft(sourceSet = sourceSets["main"], lateApply = true) { + remap(tasks.shadowJar.get()) } } @@ -140,7 +162,21 @@ dependencies { "modImplementation"("com.simibubi.create:create-fabric-${"minecraft_version"()}:${"create_fabric_version"()}+mc${"minecraft_version"()}") { exclude(group = "com.github.llamalad7.mixinextras", module = "mixinextras-fabric") } - compileOnly("io.github.llamalad7:mixinextras-common:${"mixin_extras_version"()}") +} + +val mergeJars = tasks.register("mergeJars") { + group = "build" + description = "Merges the platform shadow jars into a single jar" + archiveBaseName.set("archives_base_name"()) + archiveVersion.set("modVersion"()) + subprojects.map { it.tasks["remapShadowJar"] }.forEach { + dependsOn(it) + from(it) + } +} + +tasks.assemble { + dependsOn(mergeJars) } fun setup() { @@ -151,10 +187,10 @@ fun setup() { println("Build #$buildNumber") } println() - println("Current branch: ${Git.currentBranch()}") - println("Current commit: ${Git.hash()}") - if(Git.isDirty()) { - var changes = Git.getUncommitedChanges().split("\n").toMutableList() + println("Current branch: ${git.currentBranch()}") + println("Current commit: ${git.hash()}") + if(git.isDirty()) { + var changes = git.getUncommitedChanges().split("\n").toMutableList() val maxChanges = 10 if(changes.size > maxChanges) { changes = changes.subList(0, maxChanges) @@ -169,21 +205,10 @@ fun setup() { ext["modVersion"] = "mod_version"() + (buildNumber?.let { "-build.$it" } ?: "") - forgix { - group = "maven_group"() - mergedJarName = "${"archives_base_name"()}-${"modVersion"()}.jar" - outputDir = "build/libs" - } - - tasks.mergeJars { - dependsOn("assemble") - } - tasks.assemble { subprojects.forEach { this.dependsOn(it.tasks.named("assemble")) } - finalizedBy("mergeJars") } findAndLoadProperties() diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index c0663f9..fff7ca3 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -36,14 +36,4 @@ dependencies { plugin(id = "xyz.wagyourtail.unimined", version = "unimined_version"()) plugin(id = "com.github.johnrengelman.shadow", version = "shadow_version"()) - plugin(id = "io.github.pacifistmc.forgix", version = "forgix_version"()) } - -gradlePlugin { - plugins { - create("budget-architectury") { - id = "budget-architectury" - implementationClass = "BudgetArchPlugin" - } - } -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Git.kt b/buildSrc/src/main/kotlin/Git.kt index 1e10d8a..628ad7c 100644 --- a/buildSrc/src/main/kotlin/Git.kt +++ b/buildSrc/src/main/kotlin/Git.kt @@ -1,8 +1,10 @@ -import xyz.wagyourtail.unimined.util.FinalizeOnWrite -import xyz.wagyourtail.unimined.util.MustSet -import java.nio.file.Path +import org.gradle.api.Project +import java.io.File -object Git { +val Project.git + get() = Git(rootProject.rootDir) + +class Git(val repository: File) { // does the current git repository have uncommitted changes? fun isDirty() = git("status", "--porcelain").isNotBlank() @@ -19,10 +21,8 @@ object Git { private fun git(vararg args: String): String { val process = ProcessBuilder("git", *args) - .directory(repository.toFile()) + .directory(repository) .start() return process.inputStream.bufferedReader().readText() } - - var repository by FinalizeOnWrite(MustSet()) } \ No newline at end of file diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 308a163..bf8e8d8 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -23,7 +23,9 @@ dependencies { modImplementation("com.simibubi.create:create-${"minecraft_version"()}:${"create_forge_version"()}:slim") { isTransitive = false } modImplementation("com.tterrag.registrate:Registrate:${"registrate_version"()}") modImplementation("com.jozufozu.flywheel:flywheel-forge-${"flywheel_mc_version"()}:${"flywheel_version"()}") - implementation("io.github.llamalad7:mixinextras-forge:${"mixin_extras_version"()}") // TODO jarjar this + implementation("io.github.llamalad7:mixinextras-forge:${"mixin_extras_version"()}") { + "include"(this) + } } operator fun String.invoke(): String = rootProject.ext[this] as? String ?: error("Property $this is not defined") \ No newline at end of file