plugins { id "com.github.johnrengelman.shadow" version "8.1.1" } architectury { platformSetupLoomIde() neoForge() } configurations { common shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. compileClasspath.extendsFrom common runtimeClasspath.extendsFrom common } processResources { filesMatching("META-INF/neoforge.mods.toml") { expand "version": project.version } inputs.property "version", project.version } repositories { maven { url "https://www.cursemaven.com" } maven { url "https://dl.cloudsmith.io/public/geckolib3/geckolib/maven" } maven { name "Modmaven" url "https://modmaven.dev/" // For Gradle 5.1 and above, limit it to just AE2 content { includeGroup 'appeng' } } } sourceSets { serverComponent { compileClasspath += main.compileClasspath runtimeClasspath += main.runtimeClasspath } } processServerComponentResources { filesMatching("META-INF/neoforge.mods.toml") { expand "version": project.version } inputs.property "version", project.version } loom { } def depProjects = [":api", ":runtime", ":default-plugin"] dependencies { neoForge("net.neoforged:neoforge:${rootProject.neoforge_version}") modApi("me.shedaniel.cloth:cloth-config-neoforge:${cloth_config_version}") modApi("dev.architectury:architectury-neoforge:${architectury_version}") depProjects.forEach { common(project(path: it, configuration: "namedElements")) { transitive false } shadowCommon(project(path: it, configuration: "transformProductionNeoForge")) { transitive false } } } def modRuntime(str) { dependencies.modLocalRuntime(str) } shadowJar { configurations = [project.configurations.shadowCommon] archiveClassifier = "dev-shadow" } remapJar { input.set shadowJar.archiveFile dependsOn shadowJar archiveClassifier = null } task renameJarForPublication(type: Zip, dependsOn: remapJar) { from remapJar.archiveFile.map { zipTree(it) } metadataCharset "UTF-8" archiveExtension = "jar" destinationDirectory = base.libsDirectory archiveClassifier = project.name } assemble.dependsOn renameJarForPublication jar { archiveClassifier = "dev" } java { withSourcesJar() } sourcesJar { afterEvaluate { depProjects.forEach { def depSources = project(it).sourcesJar dependsOn depSources from depSources.archiveFile.map { zipTree(it) } } } } task serverOnlyJar(type: Jar, dependsOn: [remapJar]) { archiveClassifier = "server-only" from(zipTree(remapJar.archiveFile.get().asFile)) { exclude "META-INF/neoforge.mods.toml", "mezz/**", "me/shedaniel/rei/forge/RoughlyEnoughItemsForge.class", "me/shedaniel/rei/forge/JEIStub.class" } from(sourceSets.serverComponent.output) } tasks.build { dependsOn tasks.serverOnlyJar } components.java { withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { skip() } } publishing { publications { mavenNeoForge(MavenPublication) { artifactId = rootProject.name + "-" + project.name from components.java } ["api", "default-plugin"].forEach { projectName -> def remapMojang = tasks.create("remapMojangJarFor$projectName", net.fabricmc.loom.task.RemapJarTask) { inputFile = project(":" + projectName).tasks.jar.archiveFile archiveClassifier = "mojang-remapped-$projectName" targetNamespace = "mojang" } def remapMojangSourcesJar = tasks.create("remapMojangSourcesFor$projectName", net.fabricmc.loom.task.RemapSourcesJarTask) { inputFile = project(":" + projectName).tasks.sourcesJar.archiveFile archiveClassifier = "mojang-remapped-$projectName-sources" targetNamespace = "mojang" } create(projectName + "NeoForge", MavenPublication.class) { publication -> publication.artifactId = rootProject.name + "-" + projectName + "-neoforge" project.afterEvaluate { def project = project(":" + projectName) remapMojang.inputFile = project.fakeForgeJar.archiveFile def normalArtifact, sourceArtifact publication.artifact(remapMojang) { classifier null; normalArtifact = it } publication.artifact(remapMojangSourcesJar) { builtBy remapMojangSourcesJar classifier "sources" sourceArtifact = it } from components.java publication.setArtifacts([normalArtifact, sourceArtifact]) } } } } } unifiedPublishing { if (rootProject.neoforge_pr != "") return project { displayName = "[NeoForge $rootProject.supported_version] v$project.version" releaseType = "beta" gameVersions = ["1.21.9"] gameLoaders = ["neoforge"] changelog = rootProject.releaseChangelog mainPublication renameJarForPublication relations { depends { curseforge = "architectury-api" modrinth = "architectury-api" } depends { curseforge = "cloth-config" modrinth = "cloth-config" } } if (project.hasProperty("danielshe_curse_api_key") || System.getenv("danielshe_curse_api_key") != null) { curseforge { token = project.hasProperty("danielshe_curse_api_key") ? project.property("danielshe_curse_api_key") : System.getenv("danielshe_curse_api_key") id = "310111" gameVersions.addAll "Java 17" relations { depends "roughly-enough-items-hacks" } } } if (project.hasProperty("modrinth_key") || System.getenv("modrinth_key") != null) { modrinth { token = project.hasProperty("modrinth_key") ? project.property("modrinth_key") : System.getenv("modrinth_key") id = "nfn13YXA" version = "$project.version+$project.name" } } } project { displayName = "[NeoForge $rootProject.supported_version] v$project.version" releaseType = "release" gameVersions = ["1.21.9"] gameLoaders = ["neoforge"] changelog = rootProject.releaseChangelog mainPublication serverOnlyJar relations { depends { curseforge = "architectury-api" modrinth = "architectury-api" } depends { curseforge = "cloth-config" modrinth = "cloth-config" } } if (project.hasProperty("danielshe_curse_api_key") || System.getenv("danielshe_curse_api_key") != null) { curseforge { token = project.hasProperty("danielshe_curse_api_key") ? project.property("danielshe_curse_api_key") : System.getenv("danielshe_curse_api_key") id = "567899" gameVersions.addAll "Java 17" } } if (project.hasProperty("modrinth_key") || System.getenv("modrinth_key") != null) { modrinth { releaseType = "release" token = project.hasProperty("modrinth_key") ? project.property("modrinth_key") : System.getenv("modrinth_key") id = "OM4ZYSws" version = "$project.version+$project.name" } } } }