plugins { id "architectury-plugin" version "3.4-SNAPSHOT" id "dev.architectury.loom" version "1.1-SNAPSHOT" apply false id "maven-publish" id 'com.matthewprenger.cursegradle' version '1.4.0' apply false id 'com.palantir.git-version' version '1.0.0' id 'se.bjurr.gitchangelog.git-changelog-gradle-plugin' version '1.79.0' id "com.modrinth.minotaur" version "2.+" apply false id("com.diffplug.spotless") version "6.18.0" apply false } architectury { minecraft = rootProject.minecraft_version } ext.archives_base_name = 'modernfix-mc' + minecraft_version allprojects { apply plugin: "java" apply plugin: "architectury-plugin" apply plugin: "maven-publish" apply plugin: "com.diffplug.spotless" spotless { java { removeUnusedImports() } } group = 'org.embeddedt' // extract base version from tag, generate other metadata ourselves def details = versionDetails() def plusIndex = details.lastTag.indexOf("+") if(plusIndex == -1) { plusIndex = details.lastTag.length() } def baseVersion = details.lastTag.substring(0, plusIndex) def dirtyMarker = details.isCleanTag ? "" : ".dirty" def commitHashMarker = details.commitDistance > 0 ? ("." + details.gitHash) : "" def preMarker = (details.commitDistance > 0 || !details.isCleanTag) ? ("-beta." + details.commitDistance) : "" def versionString = "${baseVersion}${preMarker}+mc${minecraft_version}${commitHashMarker}${dirtyMarker}" version = versionString archivesBaseName = rootProject.archives_base_name + '-' + project.name sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 repositories { maven { url 'https://modmaven.dev/' } maven { url "https://cursemaven.com" content { includeGroup "curse.maven" } } exclusiveContent { forRepository { maven { name = "Modrinth" url = "https://api.modrinth.com/maven" } } filter { includeGroup "maven.modrinth" } } maven { name = 'ParchmentMC' url = 'https://maven.parchmentmc.org' } maven { // Shedaniel's maven (Architectury API) url = "https://maven.architectury.dev" content { includeGroup "me.shedaniel" } } maven { // saps.dev Maven (KubeJS and Rhino) url = "https://maven.saps.dev/minecraft" content { includeGroup "dev.latvian.mods" } } maven { // CTM url "https://maven.tterrag.com/" } maven { url 'https://maven.blamejared.com' } repositories { maven { name = "Fuzs Mod Resources" url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" } } maven { url 'https://maven.terraformersmc.com/releases' } } } subprojects { apply plugin: "dev.architectury.loom" loom { silentMojangMappingsLicense() } dependencies { minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" mappings loom.officialMojangMappings() } processResources { def mixinFileList = [] def mixinDirectory = file("src/main/java/org/embeddedt/modernfix/" + project.name + "/mixin") fileTree(mixinDirectory).visit { FileVisitDetails details -> if(details.file.isFile()) { def fileName = mixinDirectory.relativePath(details.file).toString().replaceFirst(/\.java$/, "").replace('/', '.') mixinFileList << fileName } } def mixinClassesStringB = new StringBuilder() for(int i = 0; i < mixinFileList.size(); i++) { mixinClassesStringB.append(" \"") mixinClassesStringB.append(mixinFileList.get(i)) mixinClassesStringB.append('"') if(i < (mixinFileList.size() - 1)) mixinClassesStringB.append(',') mixinClassesStringB.append('\n') } def replacements = [ mixin_classes: mixinClassesStringB.toString() ] inputs.properties replacements def filePattern = "modernfix-" + project.name + ".mixins.json" filesMatching(filePattern) { expand replacements } } } tasks.withType(JavaCompile) { // ensure that the encoding is set to UTF-8, no matter what the system default is // this fixes some edge cases with special characters not displaying correctly // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html // If Javadoc is generated, this must be specified in that task too. options.encoding = "UTF-8" // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. // We'll use that if it's available, but otherwise we'll use the older option. def targetVersion = 8 /* if (JavaVersion.current().isJava9Compatible()) { options.release = targetVersion } */ } task generateChangelog(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) { def details = versionDetails(); if(details.commitDistance > 0) { fromRef = details.lastTag; } else { def secondLastTagCmd = "git describe --abbrev=0 " + details.lastTag + "^" def secondLastTag = secondLastTagCmd.execute().text.trim() fromRef = secondLastTag; } file = new File("CHANGELOG.md"); def otherTemplateContent = new File('gradle/changelog.mustache').getText('UTF-8'); templateContent = "## Changes since " + fromRef + "\n" + otherTemplateContent; toCommit = "HEAD"; } tasks.register('checkCleanTag') { doLast { def details = versionDetails() if (!details.isCleanTag || versionDetails().commitDistance != 0) { throw new GradleException('Not a clean tree.') } } }