import org.gradle.plugins.ide.idea.model.IdeaLanguageLevel import org.jetbrains.gradle.ext.runConfigurations import org.jetbrains.gradle.ext.settings plugins { id("org.jetbrains.gradle.plugin.idea-ext") version "1.3" id("com.gtnewhorizons.retrofuturagradle") version "2.0.2" id("com.github.gmazzo.buildconfig") version "6.0.7" id("io.freefair.lombok") version "9.1.0" } group = "dev.redstudio" version = "1.0" // Versioning must follow Ragnarök versioning convention: https://github.com/Red-Studio-Ragnarok/Commons/blob/main/Ragnar%C3%B6k%20Versioning%20Convention.md val id = project.name.lowercase() val plugin = "${project.group}.${id}.asm.${project.name}Plugin" val jvmCommonArgs = "-Dfile.encoding=UTF-8 -XX:+UseStringDeduplication" val redCoreVersion = "0.7" val configAnytimeVersion = "3.0" minecraft { mcVersion = "1.12.2" username = "Desoroxxx" extraRunJvmArguments = listOf("-Dforge.logging.console.level=debug", "-Dfml.coreMods.load=${plugin}") + jvmCommonArgs.split(" ") } repositories { arrayOf("Release", "Beta", "Dev").forEach { repoType -> maven { name = "Red Studio - $repoType" url = uri("https://repo.redstudio.dev/${repoType.lowercase()}") content { includeGroup("dev.redstudio") } } } maven { name = "Cleanroom" url = uri("https://maven.cleanroommc.com") content { includeGroup("com.cleanroommc") } } mavenCentral() mavenLocal() } dependencies { implementation("dev.redstudio:Red-Core-MC:1.8-1.12-$redCoreVersion") implementation("com.cleanroommc:configanytime:$configAnytimeVersion") } buildConfig { packageName("${project.group}.${id}") className("ProjectConstants") documentation.set("This class defines constants for ${project.name}.\n

\nThey are automatically updated by Gradle.") useJavaOutput() // Details buildConfigField("ID",id) buildConfigField("NAME", project.name) buildConfigField("VERSION", project.version.toString()) // Versions buildConfigField("RED_CORE_VERSION", redCoreVersion) buildConfigField("CONFIG_ANYTIME_VERSION", configAnytimeVersion) // Loggers buildConfigField("org.apache.logging.log4j.Logger", "LOGGER", "org.apache.logging.log4j.LogManager.getLogger(NAME)") buildConfigField("dev.redstudio.redcore.logging.RedLogger", "RED_LOGGER", """new RedLogger(NAME, "https://tangled.org/desoroxxx.redstudio.dev/${project.name}/issues/new", LOGGER)""") } // Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod java { toolchain { languageVersion.set(JavaLanguageVersion.of(8)) vendor.set(JvmVendorSpec.ADOPTIUM) } if (!project.version.toString().contains("Dev")) withSourcesJar() // Generate sources jar, for releases } tasks { processResources { val expandProperties = mapOf( "version" to project.version, "name" to project.name, "id" to id ) inputs.properties(expandProperties) filesMatching("**/*.*") { val exclusions = arrayOf(".png") if (!exclusions.any { path.endsWith(it) }) expand(expandProperties) } } val processReadme by registering { val input = rootProject.file("README.md") val output = layout.buildDirectory.file("processed-readme/README.md") inputs.file(input) outputs.file(output) doLast { val content = input.readText() val firstHash = content.indexOf('#') val lastSeparator = content.lastIndexOf("---") val trimmed = when { firstHash != -1 && lastSeparator > firstHash -> content.substring(firstHash, lastSeparator) firstHash != -1 -> content.substring(firstHash) else -> content } output.get().asFile.parentFile.mkdirs() output.get().asFile.writeText(trimmed.trim()) } } withType { dependsOn(processReadme) from(processReadme.map { it.outputs.files }) from(rootProject.file("LICENSE")) from(rootProject.file("CHANGELOG.md")) manifest { attributes( "ModSide" to "CLIENT", "FMLCorePlugin" to plugin, "FMLCorePluginContainsFMLMod" to "true", "ForceLoadAsMod" to "true" ) } } withType{ options.encoding = "UTF-8" options.isFork = true options.forkOptions.jvmArgs = jvmCommonArgs.split(" ") } } idea { module { inheritOutputDirs = true excludeDirs.addAll(setOf(".gradle", ".idea", "build", "gradle", "run", "gradlew", "gradlew.bat", "desktop.ini").map(::file)) } project { settings { jdkName = "1.8" languageLevel = IdeaLanguageLevel("JDK_1_8") runConfigurations { listOf("Client", "Server", "Obfuscated Client", "Obfuscated Server", "Vanilla Client", "Vanilla Server").forEach { name -> create(name, org.jetbrains.gradle.ext.Gradle::class.java) { val prefix = name.substringBefore(" ").let { if (it == "Obfuscated") "Obf" else it } val suffix = name.substringAfter(" ").takeIf { it != prefix } ?: "" taskNames = setOf("run$prefix$suffix") jvmArgs = jvmCommonArgs } } } } } }