plugins { id 'idea' id 'java' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'org.spongepowered.mixin' version '0.7-SNAPSHOT' id 'org.parchmentmc.librarian.forgegradle' version '1.+' } /* apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle' if (project.hasProperty('secretFile')) { loadSecrets(new File((String) findProperty('secretFile'))) } */ if (System.getenv('BUILD_NUMBER') != null) { version += "." + System.getenv('BUILD_NUMBER') } base { archivesName = "${mod_id}-forge-${minecraft_version}" } mixin { add sourceSets.main, "${mod_id}.refmap.json" config "${mod_id}.mixins.json" config "${mod_id}.forge.mixins.json" } minecraft { mappings channel: 'parchment', version: "${parchment_mappings}" copyIdeResources = true if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) { accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') } runs { client { workingDirectory project.file('run') ideaModule "${rootProject.name}.${project.name}.main" taskName 'Client' property 'mixin.env.remapRefMap', 'true' property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" //args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json" mods { modClientRun { source sourceSets.main source project(":Common").sourceSets.main } } } server { workingDirectory project.file('run') ideaModule "${rootProject.name}.${project.name}.main" taskName 'Server' property 'mixin.env.remapRefMap', 'true' property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" //args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json" mods { modServerRun { source sourceSets.main source project(":Common").sourceSets.main } } } data { workingDirectory project.file('run') ideaModule "${rootProject.name}.${project.name}.main" args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') taskName 'Data' property 'mixin.env.remapRefMap', 'true' property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" //args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json" mods { modDataRun { source sourceSets.main source project(":Common").sourceSets.main } } } } } sourceSets.main.resources.srcDir 'src/generated/resources' repositories { flatDir { dirs 'libs' } maven { url 'https://jitpack.io' } } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" compileOnly project(":Common") compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:${mixinextras_version}")) runtimeOnly(annotationProcessor("io.github.llamalad7:mixinextras-forge:${mixinextras_version}")) jarJar(group: 'io.github.llamalad7', name: 'mixinextras-forge', version: "[${mixinextras_version},)") //implementation fg.deobf("net.darkhax.gamestages:GameStages-Forge-1.19.2:11.0.2") //implementation fg.deobf("net.darkhax.bookshelf:Bookshelf-Forge-1.19.3:17.0.2") annotationProcessor 'org.spongepowered:mixin:0.8.5-SNAPSHOT:processor' fileTree("libs").matching { include "*.jar" }.each { String filename = it.getName(); filename = filename.substring(0, filename.length() - 4); int lastDash = filename.lastIndexOf("-"); filename = filename.substring(0, lastDash) + ":" + filename.substring(lastDash+1, filename.length()); implementation fg.deobf("blank:${filename}") } // Hack fix for now, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transitive dependencies request 6.0+ implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } } } tasks.withType(JavaCompile).configureEach { source(project(":Common").sourceSets.main.allSource) } tasks.withType(Javadoc).configureEach { source(project(":Common").sourceSets.main.allJava) } tasks.named("sourcesJar", Jar) { from(project(":Common").sourceSets.main.allSource) } processResources { from project(":Common").sourceSets.main.resources } reobf { jarJar {} } jar.finalizedBy('reobfJar') publishing { publications { mavenJava(MavenPublication) { artifactId base.archivesName.get() from components.java fg.component(it) } } repositories { maven { url "file://" + System.getenv("local_maven") } } } // Merge the resources and classes into the same directory. // This is done because java expects modules to be in a single directory. // And if we have it in multiple we have to do performance intensive hacks like having the UnionFileSystem // This will eventually be migrated to ForgeGradle so modders don't need to manually do it. But that is later. sourceSets.each { def dir = layout.buildDirectory.dir("sourcesSets/$it.name") it.output.resourcesDir = dir it.java.destinationDirectory = dir }