From df32d547c9594f5283903870248ab5acc9a3420b Mon Sep 17 00:00:00 2001 From: Ted Senft Date: Fri, 13 Dec 2024 20:17:45 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=98=20moment=20#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/build.gradle.kts | 92 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 2 deletions(-) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index cc8b06e13..491de8d42 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,22 +1,110 @@ +import dev.compactmachines.GanderConstants +import gradle.kotlin.dsl.accessors._53f21c2e2286c58eadab8fd2d7f5601a.* +import java.text.SimpleDateFormat +import java.util.* + var envVersion: String = System.getenv("VERSION") ?: "9.9.9" if (envVersion.startsWith("v")) envVersion = envVersion.trimStart('v') plugins { - java + id("java-library") + id("idea") + id("org.jetbrains.gradle.plugin.idea-ext") + id("net.neoforged.moddev.legacyforge") id("maven-publish") - id("gander-convention") } base { archivesName = project.name group = "dev.compactmods.gander" version = envVersion + + libsDirectory = rootProject.layout.projectDirectory.dir("libs/${project.name}") +} + +idea.module { + if (!GanderConstants.IS_CI) { + isDownloadSources = true + isDownloadJavadoc = true + } + + excludeDirs.addAll( + files( + ".gradle", + "build", + "run" + ) + ) +} + +java { + toolchain.vendor.set(JvmVendorSpec.JETBRAINS) + toolchain.languageVersion.set(JavaLanguageVersion.of(17)) } +neoForge { + version = GanderConstants.FORGE_VERSION + // not currently usable since the AT included in legacy forge + // does not itself validate, many unused/nonexistent AT entries exist in it + // validateAccessTransformers.convention(true) + + parchment { + minecraftVersion = GanderConstants.PARCHMENT_VERSION + mappingsVersion = GanderConstants.PARCHMENT_MAPPINGS + } + + // apply this modules AT file if it exists + // also mark for publishing with maven publication + val atFile = file("src/main/resources/META-INF/accesstransformer.cfg") + + if (atFile.exists()) { + accessTransformers { + from(atFile) + publish(atFile) + } + } +} + +tasks.jar { + + val gitVersion = providers.exec { + commandLine("git", "rev-parse", "HEAD") + }.standardOutput.asText.get() + + manifest { + from(file("src/main/resources/META-INF/MANIFEST.MF")) + + val now = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(Date()) + attributes( + mapOf( + "Main-Commit" to gitVersion + ) + ) + } +} + +dependencies { + // not included with MDG currently + // does not affect runtime or production + // safe to have at compile time with no issues + compileOnly("org.jetbrains:annotations:26.0.1") + annotationProcessor("org.spongepowered:mixin:0.8.5:processor") +} + +tasks.withType { + options.encoding = "UTF-8" + + if (!GanderConstants.IS_CI) { + options.compilerArgs.addAll(arrayOf("-Xmaxerrs", "9000")) + } +} + + val PACKAGES_URL = System.getenv("GH_PKG_URL") ?: "https://maven.pkg.github.com/compactmods/gander" publishing { publications.register(project.name) { + artifactId = "core" version = envVersion from(components.getByName("java")) }