plugins { java id("fabric-loom") version "1.0.+" id("io.github.juuxel.loom-quiltflower") version "1.7.+" id("com.modrinth.minotaur") version "2.4.+" id("me.hypherionmc.cursegradle") version "2.+" id("com.github.breadmoirai.github-release") version "2.+" `maven-publish` id("io.github.p03w.machete") version "1.+" id("org.ajoberstar.grgit") version "5.0.0" } val ciRun = System.getenv().containsKey("GITHUB_ACTIONS") group = "dev.isxander" version = "0.1.0" if (ciRun) version = grgit.head().abbreviatedId val testmod by sourceSets.registering { compileClasspath += sourceSets.main.get().compileClasspath runtimeClasspath += sourceSets.main.get().runtimeClasspath } loom { runs { register("testmod") { client() ideConfigGenerated(true) name("Test Mod") source(testmod.get()) } } createRemapConfigurations(testmod.get()) } repositories { mavenCentral() maven("https://maven.terraformersmc.com") } val minecraftVersion: String by project val fabricLoaderVersion: String by project dependencies { minecraft("com.mojang:minecraft:$minecraftVersion") mappings("net.fabricmc:yarn:$minecraftVersion+build.+:v2") modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion") modImplementation(fabricApi.module("fabric-resource-loader-v0", "0.60.0+1.19.2")) "testmodImplementation"(sourceSets.main.get().output) "modTestmodImplementation"("com.terraformersmc:modmenu:4.0.6") } java { withSourcesJar() withJavadocJar() } tasks { processResources { val modId: String by project val modName: String by project val modDescription: String by project val githubProject: String by project inputs.property("id", modId) inputs.property("group", project.group) inputs.property("name", modName) inputs.property("description", modDescription) inputs.property("version", project.version) inputs.property("github", githubProject) filesMatching(listOf("fabric.mod.json", "quilt.mod.json")) { expand( "id" to modId, "group" to project.group, "name" to modName, "description" to modDescription, "version" to project.version, "github" to githubProject, ) } } remapJar { archiveClassifier.set("fabric-$minecraftVersion") } remapSourcesJar { archiveClassifier.set("fabric-$minecraftVersion-sources") } register("releaseMod") { group = "mod" dependsOn("modrinth") dependsOn("modrinthSyncBody") dependsOn("curseforge") dependsOn("publishModPublicationToReleasesRepository") dependsOn("githubRelease") } } java { withSourcesJar() } val changelogText = file("changelogs/${project.version}.md").takeIf { it.exists() }?.readText() ?: "No changelog provided." val modrinthId: String by project if (modrinthId.isNotEmpty()) { modrinth { token.set(findProperty("modrinth.token")?.toString()) projectId.set(modrinthId) versionNumber.set("${project.version}") versionType.set("release") uploadFile.set(tasks["remapJar"]) gameVersions.set(listOf("1.19", "1.19.1", "1.19.2")) loaders.set(listOf("fabric", "quilt")) changelog.set(changelogText) syncBodyFrom.set(file("README.md").readText()) } } val curseforgeId: String by project if (hasProperty("curseforge.token") && curseforgeId.isNotEmpty()) { curseforge { apiKey = findProperty("curseforge.token") project(closureOf { mainArtifact(tasks["remapJar"], closureOf { displayName = "${project.version}" }) id = curseforgeId releaseType = "release" addGameVersion("1.19") addGameVersion("1.19.1") addGameVersion("1.19.2") addGameVersion("Fabric") addGameVersion("Java 17") changelog = changelogText changelogType = "markdown" }) options(closureOf { forgeGradleIntegration = false }) } } githubRelease { token(findProperty("github.token")?.toString()) val githubProject: String by project val split = githubProject.split("/") owner(split[0]) repo(split[1]) tagName("${project.version}") targetCommitish(grgit.branch.toString()) body(changelogText) releaseAssets(tasks["remapJar"].outputs.files) } publishing { publications { create("mod") { groupId = "dev.isxander" artifactId = "yet-another-config-lib" from(components["java"]) } } repositories { val username = "xander-repo.username".let { System.getenv(it) ?: findProperty(it) }?.toString() val password = "xander-repo.password".let { System.getenv(it) ?: findProperty(it) }?.toString() if (username != null && password != null) { maven(url = "https://maven.isxander.dev/releases") { name = "Releases" credentials { this.username = username this.password = password } } maven(url = "https://maven.isxander.dev/snapshots") { name = "Snapshots" credentials { this.username = username this.password = password } } } else { println("Xander Maven credentials not satisfied.") } } }