From ddca97f679af638b35441469ab6e775a76277cec Mon Sep 17 00:00:00 2001 From: TomTheFurry Date: Sun, 19 Jun 2022 16:57:35 +0800 Subject: [PATCH] Unroll the build script Still issue on running ide causes SHA-256 digest error??? --- build.gradle | 492 ++++++++++++++++++++++++++------------------ common/build.gradle | 203 +++++++++++++++++- fabric/build.gradle | 186 ++++++++++++++++- forge/build.gradle | 181 +++++++++++++++- gradle.properties | 2 +- 5 files changed, 857 insertions(+), 207 deletions(-) diff --git a/build.gradle b/build.gradle index d52092815..ef3b98caf 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,5 @@ import io.github.ran.jarmerger.JarMergerPlugin - buildscript { dependencies{ classpath files('plugins/DHJarMerger-1.0.jar') @@ -12,6 +11,24 @@ plugins { id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false } +apply plugin: "java" +apply plugin: "architectury-plugin" +apply plugin: "maven-publish" +apply plugin: JarMergerPlugin + +archivesBaseName = rootProject.archives_base_name +version = rootProject.mod_version +group = rootProject.maven_group + +task printConfigurations { + doLast {task -> + println "Project Name: $name configurations:" + configurations.each { + println " $it.name" + } + } +} + def writeBuildGradlePredefine(List mcVers, int mcIndex) { ArrayList redefineList = new ArrayList() for (int i=0; i - apply plugin: "dev.architectury.loom" + // For parchment mappings + maven { url "https://maven.parchmentmc.org" } - loom { - silentMojangMappingsLicense() + // used to download and compile dependencies from git repos + maven { url 'https://jitpack.io' } - if (p != project(":core")) { - accessWidenerPath.set(project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener")) + // For Manifold Preprocessor + maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } + + // Required for importing Modrinth mods + maven { + name = "Modrinth" + url = "https://api.modrinth.com/maven" + content { + includeGroup "maven.modrinth" } } - configurations { - common - shadowMe - implementation.extendsFrom shadowMe + // Required for importing CursedForge mods + maven { + url "https://www.cursemaven.com" + content { + includeGroup "curse.maven" + } } - dependencies { - minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" - // The following line declares the mojmap mappings & parchment mappings - mappings loom.layered() { - // Mojmap mappings - officialMojangMappings() - // Parchment mappings (it adds parameter mappings & javadoc) - if (rootProject.minecraft_version != "1.19") - parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip") - else - parchment("org.parchmentmc.data:parchment-1.18.2:${rootProject.parchment_version}@zip") // As 1.19 dosnt have parchment mappings yet, we use 1.18.2 mapping + // These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource + flatDir { + dirs "${rootDir}/mods/fabric" + content { + includeGroup "fabric-mod" } - - //Manifold - annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}" - - // Toml - implementation("com.electronwill.night-config:toml:${rootProject.toml_version}") - - if (p != project(":forge")) { - // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies - // Do NOT use other classes from fabric loader unless working with fabric - modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - } - - if (p != project(":core")) - common(project(":core")) { transitive false } - if (p == project(":common")) - shadowMe(project(":core")) { transitive false } } - - // Allows the jar to run standalone - jar { - manifest { - attributes 'Implementation-Title': rootProject.archives_base_name, - 'Implementation-Version': rootProject.mod_version, - 'Main-Class': 'com.seibel.lod.core.JarMain' // When changing the main of the jar change this line + flatDir { + dirs "${rootDir}/mods/forge" + content { + includeGroup "forge-mod" } } } -allprojects { p -> - apply plugin: "java" - apply plugin: "architectury-plugin" - apply plugin: "maven-publish" +processResources { + def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put + def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder + def replaceProperties = [ + version : mod_version, + mod_name : mod_name, + authors : mod_authors, + description : mod_description, + homepage : mod_homepage, + source : mod_source, + issues : mod_issues, + minecraft_version : minecraft_version, + compatible_minecraft_versions: compatible_minecraft_versions, + java_version : java_version + ] + // The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties + //TODO: Make Forge loader version also be relaced with non hardcoded value instead of "[36,42)" - archivesBaseName = rootProject.archives_base_name - version = rootProject.mod_version - group = rootProject.maven_group - - - repositories { - mavenCentral() - - // For parchment mappings - maven { url "https://maven.parchmentmc.org" } - - // used to download and compile dependencies from git repos - maven { url 'https://jitpack.io' } - - // For Manifold Preprocessor - maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } - - // Required for importing Modrinth mods - maven { - name = "Modrinth" - url = "https://api.modrinth.com/maven" - content { - includeGroup "maven.modrinth" - } - } - - // Required for importing CursedForge mods - maven { - url "https://www.cursemaven.com" - content { - includeGroup "curse.maven" - } - } - - // These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource - flatDir { - dirs "${rootDir}/mods/fabric" - content { - includeGroup "fabric-mod" - } - } - flatDir { - dirs "${rootDir}/mods/forge" - content { - includeGroup "forge-mod" - } - } + inputs.properties replaceProperties + replaceProperties.put 'project', project + filesMatching(resourceTargets) { + expand replaceProperties } - - // Put stuff from gradle.properties into the mod info - processResources { - def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put - def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder - def replaceProperties = [ - version : mod_version, - mod_name : mod_name, - authors : mod_authors, - description : mod_description, - homepage : mod_homepage, - source : mod_source, - issues : mod_issues, - minecraft_version : minecraft_version, - compatible_minecraft_versions: compatible_minecraft_versions, - java_version : java_version - ] - // The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties - //TODO: Make Forge loader version also be relaced with non hardcoded value instead of "[36,42)" - - inputs.properties replaceProperties - replaceProperties.put 'project', project - filesMatching(resourceTargets) { - expand replaceProperties - } - - intoTargets.each { target -> - if (file(target).exists()) { - copy { - from(sourceSets.main.resources) { - include resourceTargets - expand replaceProperties - } - into target + intoTargets.each { target -> + if (file(target).exists()) { + copy { + from(sourceSets.main.resources) { + include resourceTargets + expand replaceProperties } + into target } } } - - - // Copies the correct accesswidener and renames it - task copyAccessWidener(type: Copy) { - from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener") - into(file(p.file("build/resources/main"))) - rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener" - } - - task copyCoreResources(type: Copy) { - from fileTree(project(":core").file("src/main/resources")) - into p.file("build/resources/main") - } - - task copyCommonResources(type: Copy) { - from fileTree(project(":common").file("src/main/resources")) - into p.file("build/resources/main") - } - - - // Is this necessary for running the fabric build - if (p == project(":common")) { - println "Copying [common/src/main/resources/${acsessWidenerVersion}.lod.accesswidner] to [fabric/build/resources/main]." - - copy { - from project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener") - into project(":fabric").file("build/resources/main") - rename "${acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener" - } - } - - tasks.withType(JavaCompile) { - // Add Manifold Preprocessor -// def excapedMCVersion = rootProject.minecraft_version.replace(".", "_") -// options.compilerArgs += ['-Xplugin:Manifold', "-AMC_VERSION_${excapedMCVersion}"] -// - //options.compilerArgs += ['-deprecation'] - //options.compilerArgs += ['-verbose'] - //options.compilerArgs += ['-Xlint:unchecked'] - //options.compilerArgs += ['-Xdiags:verbose'] - //options.compilerArgs += ['-Xprint'] - //options.compilerArgs += ['-XprintProcessorInfo'] - //options.compilerArgs += ['-XprintRounds'] - - // println options.compilerArgs - - // Set the java version - if (p != project(":core")) { - options.compilerArgs += ['-Xplugin:Manifold'] - options.release = rootProject.java_version as Integer - } else if (p == project(":core")) { - options.release = 8; // Core should use Java 8 no matter what - } - // TODO: make everything use java 8 -// options.release = 8 // Use Java 8 for everything so back porting is easier - } - - java { - withSourcesJar() - } - - // Disable running & remapping in core and common - if (p == project(":core") || p == project(":common")) { - runClient.enabled = false - runServer.enabled = false - } } +// Copies the correct accesswidener and renames it +task copyAccessWidener(type: Copy) { + from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener") + into(file("build/resources/main")) + rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener" +} + +task copyCoreResources(type: Copy) { + from fileTree(project(":core").file("src/main/resources")) + into file("build/resources/main") +} + +task copyCommonResources(type: Copy) { + from fileTree(project(":common").file("src/main/resources")) + into file("build/resources/main") +} + +java { + withSourcesJar() +} + +//runClient.enabled = false +//runServer.enabled = false // this deletes the merged folder so we don't carry over // the previous merges to each new build job in the CI/CD pipeline task deleteMerged(type: Delete) { delete files("./Merged") } + + +// ===============================CORE Gradle basically================================ +subprojects { p -> + if (p == project(":core")) { + + apply plugin: "java" + apply plugin: "architectury-plugin" + apply plugin: "maven-publish" + apply plugin: "dev.architectury.loom" + + p.archivesBaseName = rootProject.archives_base_name + p.version = rootProject.mod_version + p.group = rootProject.maven_group + + loom { + silentMojangMappingsLicense() + } + + configurations { + common + shadowMe + implementation.extendsFrom shadowMe + } + + dependencies { + minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" + // The following line declares the mojmap mappings & parchment mappings + mappings loom.layered() { + // Mojmap mappings + officialMojangMappings() + // Parchment mappings (it adds parameter mappings & javadoc) + if (rootProject.minecraft_version != "1.19") + parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip") + else + parchment("org.parchmentmc.data:parchment-1.18.2:${rootProject.parchment_version}@zip") // As 1.19 dosnt have parchment mappings yet, we use 1.18.2 mapping + } + + //Manifold + annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}" + + // Toml + implementation("com.electronwill.night-config:toml:${rootProject.toml_version}") + + // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies + // Do NOT use other classes from fabric loader unless working with fabric + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + } + + // Allows the jar to run standalone + jar { + manifest { + attributes 'Implementation-Title': rootProject.archives_base_name, + 'Implementation-Version': rootProject.mod_version, + 'Main-Class': 'com.seibel.lod.core.JarMain' + // When changing the main of the jar change this line + } + } + + task printConfigurations { + doLast {task -> + println "Project Name: $p.name configurations:" + configurations.each { + println " $it.name" + } + } + } + + repositories { + mavenCentral() + + // For parchment mappings + maven { url "https://maven.parchmentmc.org" } + + // used to download and compile dependencies from git repos + maven { url 'https://jitpack.io' } + + // For Manifold Preprocessor + maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } + + // Required for importing Modrinth mods + maven { + name = "Modrinth" + url = "https://api.modrinth.com/maven" + content { + includeGroup "maven.modrinth" + } + } + + // Required for importing CursedForge mods + maven { + url "https://www.cursemaven.com" + content { + includeGroup "curse.maven" + } + } + + // These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource + flatDir { + dirs "${rootDir}/mods/fabric" + content { + includeGroup "fabric-mod" + } + } + flatDir { + dirs "${rootDir}/mods/forge" + content { + includeGroup "forge-mod" + } + } + } + + processResources { + def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put + def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder + def replaceProperties = [ + version : mod_version, + mod_name : mod_name, + authors : mod_authors, + description : mod_description, + homepage : mod_homepage, + source : mod_source, + issues : mod_issues, + minecraft_version : minecraft_version, + compatible_minecraft_versions: compatible_minecraft_versions, + java_version : java_version + ] + // The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties + //TODO: Make Forge loader version also be relaced with non hardcoded value instead of "[36,42)" + + inputs.properties replaceProperties + replaceProperties.put 'project', project + filesMatching(resourceTargets) { + expand replaceProperties + } + + intoTargets.each { target -> + if (file(target).exists()) { + copy { + from(sourceSets.main.resources) { + include resourceTargets + expand replaceProperties + } + into target + } + } + } + } + // Copies the correct accesswidener and renames it + task copyAccessWidener(type: Copy) { + from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener") + into(file(p.file("build/resources/main"))) + rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener" + } + + task copyCoreResources(type: Copy) { + from fileTree(project(":core").file("src/main/resources")) + into p.file("build/resources/main") + } + + task copyCommonResources(type: Copy) { + from fileTree(project(":common").file("src/main/resources")) + into p.file("build/resources/main") + } + + p.tasks.withType(JavaCompile) { + // Add Manifold Preprocessor +// def excapedMCVersion = rootProject.minecraft_version.replace(".", "_") +// options.compilerArgs += ['-Xplugin:Manifold', "-AMC_VERSION_${excapedMCVersion}"] +// + //options.compilerArgs += ['-deprecation'] + //options.compilerArgs += ['-verbose'] + //options.compilerArgs += ['-Xlint:unchecked'] + //options.compilerArgs += ['-Xdiags:verbose'] + //options.compilerArgs += ['-Xprint'] + //options.compilerArgs += ['-XprintProcessorInfo'] + //options.compilerArgs += ['-XprintRounds'] + + // println options.compilerArgs + + // Set the java version + options.release = 8; // Core should use Java 8 no matter what + // TODO: make everything use java 8 +// options.release = 8 // Use Java 8 for everything so back porting is easier + } + + java { + withSourcesJar() + } + + p.runClient.enabled = false + p.runServer.enabled = false + } +} \ No newline at end of file diff --git a/common/build.gradle b/common/build.gradle index c84866111..d304172a7 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,7 +1,67 @@ +apply plugin: "java" +apply plugin: "architectury-plugin" +apply plugin: "maven-publish" +apply plugin: "dev.architectury.loom" + +archivesBaseName = rootProject.archives_base_name +version = rootProject.mod_version +group = rootProject.maven_group + architectury { common(rootProject.enabled_platforms.split(",")) } +loom { + silentMojangMappingsLicense() + accessWidenerPath.set(project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener")) +} + +configurations { + common + shadowMe + implementation.extendsFrom shadowMe +} +java { + withSourcesJar() +} + + +dependencies { + minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" + // The following line declares the mojmap mappings & parchment mappings + mappings loom.layered() { + // Mojmap mappings + officialMojangMappings() + // Parchment mappings (it adds parameter mappings & javadoc) + if (rootProject.minecraft_version != "1.19") + parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip") + else + parchment("org.parchmentmc.data:parchment-1.18.2:${rootProject.parchment_version}@zip") // As 1.19 dosnt have parchment mappings yet, we use 1.18.2 mapping + } + + //Manifold + annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}" + + // Toml + implementation("com.electronwill.night-config:toml:${rootProject.toml_version}") + + // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies + // Do NOT use other classes from fabric loader unless working with fabric + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"\ + + common(project(":core")) { transitive false } + shadowMe(project(":core")) { transitive false } +} + +// Allows the jar to run standalone +jar { + manifest { + attributes 'Implementation-Title': rootProject.archives_base_name, + 'Implementation-Version': rootProject.mod_version, + 'Main-Class': 'com.seibel.lod.core.JarMain' // When changing the main of the jar change this line + } +} + publishing { publications { mavenCommon(MavenPublication) { @@ -14,4 +74,145 @@ publishing { repositories { // Add repositories to publish to here. } -} \ No newline at end of file +} + +task printConfigurations { + doLast {task -> + println "Project Name: $name configurations:" + configurations.each { + println " $it.name" + } + } +} +repositories { + mavenCentral() + + // For parchment mappings + maven { url "https://maven.parchmentmc.org" } + + // used to download and compile dependencies from git repos + maven { url 'https://jitpack.io' } + + // For Manifold Preprocessor + maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } + + // Required for importing Modrinth mods + maven { + name = "Modrinth" + url = "https://api.modrinth.com/maven" + content { + includeGroup "maven.modrinth" + } + } + + // Required for importing CursedForge mods + maven { + url "https://www.cursemaven.com" + content { + includeGroup "curse.maven" + } + } + + // These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource + flatDir { + dirs "${rootDir}/mods/fabric" + content { + includeGroup "fabric-mod" + } + } + flatDir { + dirs "${rootDir}/mods/forge" + content { + includeGroup "forge-mod" + } + } +} + +// Copies the correct accesswidener and renames it +task copyAccessWidener(type: Copy) { + from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener") + into(file("build/resources/main")) + rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener" +} + +task copyCoreResources(type: Copy) { + from fileTree(project(":core").file("src/main/resources")) + into file("build/resources/main") +} + +task copyCommonResources(type: Copy) { + from fileTree(project(":common").file("src/main/resources")) + into file("build/resources/main") +} + +processResources { + def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put + def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder + def replaceProperties = [ + version : mod_version, + mod_name : mod_name, + authors : mod_authors, + description : mod_description, + homepage : mod_homepage, + source : mod_source, + issues : mod_issues, + minecraft_version : minecraft_version, + compatible_minecraft_versions: compatible_minecraft_versions, + java_version : java_version + ] + // The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties + //TODO: Make Forge loader version also be relaced with non hardcoded value instead of "[36,42)" + + inputs.properties replaceProperties + replaceProperties.put 'project', project + filesMatching(resourceTargets) { + expand replaceProperties + } + + intoTargets.each { target -> + if (file(target).exists()) { + copy { + from(sourceSets.main.resources) { + include resourceTargets + expand replaceProperties + } + into target + } + } + } +} + +println "Copying [common/src/main/resources/${acsessWidenerVersion}.lod.accesswidner] to [fabric/build/resources/main]." +copy { + from project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener") + into project(":fabric").file("build/resources/main") + rename "${acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener" +} + +tasks.withType(JavaCompile) { + // Add Manifold Preprocessor +// def excapedMCVersion = rootProject.minecraft_version.replace(".", "_") +// options.compilerArgs += ['-Xplugin:Manifold', "-AMC_VERSION_${excapedMCVersion}"] +// + //options.compilerArgs += ['-deprecation'] + //options.compilerArgs += ['-verbose'] + //options.compilerArgs += ['-Xlint:unchecked'] + //options.compilerArgs += ['-Xdiags:verbose'] + //options.compilerArgs += ['-Xprint'] + //options.compilerArgs += ['-XprintProcessorInfo'] + //options.compilerArgs += ['-XprintRounds'] + + // println options.compilerArgs + + // Set the java version + options.compilerArgs += ['-Xplugin:Manifold'] + options.release = rootProject.java_version as Integer + // TODO: make everything use java 8 +// options.release = 8 // Use Java 8 for everything so back porting is easier +} + +sourcesJar { +} + +runClient.enabled = false +runServer.enabled = false \ No newline at end of file diff --git a/fabric/build.gradle b/fabric/build.gradle index 095e3ed88..fb2883e93 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -2,14 +2,34 @@ plugins { id "com.github.johnrengelman.shadow" version "7.1.0" } +// From parent +apply plugin: "java" +apply plugin: "architectury-plugin" +apply plugin: "maven-publish" +apply plugin: "dev.architectury.loom" + +archivesBaseName = rootProject.archives_base_name +version = rootProject.mod_version //FIXME: Redef +group = rootProject.maven_group + version = rootProject.mod_version+"-"+rootProject.minecraft_version+"-"+new Date().format("yyyy_MM_dd_HH_mm") +loom { + silentMojangMappingsLicense() + accessWidenerPath.set(project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener")) +} + + architectury { platformSetupLoomIde() fabric() } configurations { + common + shadowMe + implementation.extendsFrom shadowMe + compileClasspath.extendsFrom common runtimeClasspath.extendsFrom common developmentFabric.extendsFrom common @@ -19,9 +39,58 @@ configurations { modImplementation.extendsFrom addModJar } +java { + withSourcesJar() +} + +jar.dependsOn(project(":core").remapJar) +remapSourcesJar.dependsOn(project(":core").remapJar) + repositories { // Required for ModMenu maven { url "https://maven.terraformersmc.com/" } + + mavenCentral() + + // For parchment mappings + maven { url "https://maven.parchmentmc.org" } + + // used to download and compile dependencies from git repos + maven { url 'https://jitpack.io' } + + // For Manifold Preprocessor + maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } + + // Required for importing Modrinth mods + maven { + name = "Modrinth" + url = "https://api.modrinth.com/maven" + content { + includeGroup "maven.modrinth" + } + } + + // Required for importing CursedForge mods + maven { + url "https://www.cursemaven.com" + content { + includeGroup "curse.maven" + } + } + + // These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource + flatDir { + dirs "${rootDir}/mods/fabric" + content { + includeGroup "fabric-mod" + } + } + flatDir { + dirs "${rootDir}/mods/forge" + content { + includeGroup "forge-mod" + } + } } def addMod(path, enabled) { @@ -32,6 +101,30 @@ def addMod(path, enabled) { } dependencies { + minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" + // The following line declares the mojmap mappings & parchment mappings + mappings loom.layered() { + // Mojmap mappings + officialMojangMappings() + // Parchment mappings (it adds parameter mappings & javadoc) + if (rootProject.minecraft_version != "1.19") + parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip") + else + parchment("org.parchmentmc.data:parchment-1.18.2:${rootProject.parchment_version}@zip") // As 1.19 dosnt have parchment mappings yet, we use 1.18.2 mapping + } + + //Manifold + annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}" + + // Toml + implementation("com.electronwill.night-config:toml:${rootProject.toml_version}") + + // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies + // Do NOT use other classes from fabric loader unless working with fabric + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + + common(project(":core")) + // Fabric loader modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" @@ -82,8 +175,6 @@ dependencies { } */ - - // Toml shadowMe("com.electronwill.night-config:toml:${rootProject.toml_version}") {} @@ -101,14 +192,64 @@ dependencies { task deleteResources(type: Delete) { delete file("build/resources/main") } +// Copies the correct accesswidener and renames it +task copyAccessWidener(type: Copy) { + from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener") + into(file("build/resources/main")) + rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener" +} + +task copyCoreResources(type: Copy) { + from fileTree(project(":core").file("src/main/resources")) + into file("build/resources/main") +} + +task copyCommonResources(type: Copy) { + from fileTree(project(":common").file("src/main/resources")) + into file("build/resources/main") +} processResources { dependsOn(copyCoreResources) dependsOn(copyCommonResources) dependsOn(copyAccessWidener) + + def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put + def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder + def replaceProperties = [ + version : mod_version, + mod_name : mod_name, + authors : mod_authors, + description : mod_description, + homepage : mod_homepage, + source : mod_source, + issues : mod_issues, + minecraft_version : minecraft_version, + compatible_minecraft_versions: compatible_minecraft_versions, + java_version : java_version + ] + // The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties + //TODO: Make Forge loader version also be relaced with non hardcoded value instead of "[36,42)" + + inputs.properties replaceProperties + replaceProperties.put 'project', project + filesMatching(resourceTargets) { + expand replaceProperties + } + + intoTargets.each { target -> + if (file(target).exists()) { + copy { + from(sourceSets.main.resources) { + include resourceTargets + expand replaceProperties + } + into target + } + } + } } -jar.dependsOn(project(":core").remapJar) -remapSourcesJar.dependsOn(project(":core").remapJar) + runClient { dependsOn(copyCoreResources) dependsOn(copyCommonResources) @@ -135,6 +276,11 @@ remapJar { } jar { + manifest { + attributes 'Implementation-Title': rootProject.archives_base_name, + 'Implementation-Version': rootProject.mod_version, + 'Main-Class': 'com.seibel.lod.core.JarMain' // When changing the main of the jar change this line + } classifier "dev" } @@ -163,3 +309,35 @@ publishing { // Add repositories to publish to here. } } + +task printConfigurations { + doLast {task -> + println "Project Name: $name configurations:" + configurations.each { + println " $it.name" + } + } +} + + +tasks.withType(JavaCompile) { + // Add Manifold Preprocessor +// def excapedMCVersion = rootProject.minecraft_version.replace(".", "_") +// options.compilerArgs += ['-Xplugin:Manifold', "-AMC_VERSION_${excapedMCVersion}"] +// + //options.compilerArgs += ['-deprecation'] + //options.compilerArgs += ['-verbose'] + //options.compilerArgs += ['-Xlint:unchecked'] + //options.compilerArgs += ['-Xdiags:verbose'] + //options.compilerArgs += ['-Xprint'] + //options.compilerArgs += ['-XprintProcessorInfo'] + //options.compilerArgs += ['-XprintRounds'] + + // println options.compilerArgs + + // Set the java version + options.compilerArgs += ['-Xplugin:Manifold'] + options.release = rootProject.java_version as Integer + // TODO: make everything use java 8 +// options.release = 8 // Use Java 8 for everything so back porting is easier +} diff --git a/forge/build.gradle b/forge/build.gradle index ba0e968ad..4154ec8d6 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -1,10 +1,23 @@ + plugins { id "com.github.johnrengelman.shadow" version "7.1.0" } +apply plugin: "java" +apply plugin: "architectury-plugin" +apply plugin: "maven-publish" +apply plugin: "dev.architectury.loom" + +archivesBaseName = rootProject.archives_base_name +version = rootProject.mod_version //FIXME: HERE repeated def +group = rootProject.maven_group + version = rootProject.mod_version+"-"+rootProject.minecraft_version+"-"+new Date().format("yyyy_MM_dd_HH_mm") + loom { + silentMojangMappingsLicense() + accessWidenerPath.set(project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener")) forge { convertAccessWideners.set(true) extraAccessWideners.add("lod.accesswidener") @@ -18,11 +31,21 @@ architectury { } configurations { + common + shadowMe + implementation.extendsFrom shadowMe + compileClasspath.extendsFrom common runtimeClasspath.extendsFrom common developmentForge.extendsFrom common } +java { + withSourcesJar() +} +jar.dependsOn(project(":core").remapJar) +remapSourcesJar.dependsOn(project(":core").remapJar) + def addMod(path, enabled) { if (enabled == "2") dependencies { modImplementation(path) } @@ -31,6 +54,27 @@ def addMod(path, enabled) { } dependencies { + + minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" + // The following line declares the mojmap mappings & parchment mappings + mappings loom.layered() { + // Mojmap mappings + officialMojangMappings() + // Parchment mappings (it adds parameter mappings & javadoc) + if (rootProject.minecraft_version != "1.19") + parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip") + else + parchment("org.parchmentmc.data:parchment-1.18.2:${rootProject.parchment_version}@zip") // As 1.19 dosnt have parchment mappings yet, we use 1.18.2 mapping + } + + //Manifold + annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}" + + // Toml + implementation("com.electronwill.night-config:toml:${rootProject.toml_version}") + + common(project(":core")) { transitive false } + // Forge loader forge "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}" @@ -57,13 +101,65 @@ dependencies { shadowMe 'org.apache.commons:commons-compress:1.21' } +// Copies the correct accesswidener and renames it +task copyAccessWidener(type: Copy) { + from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener") + into(file("build/resources/main")) + rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener" +} + +task copyCoreResources(type: Copy) { + from fileTree(project(":core").file("src/main/resources")) + into file("build/resources/main") +} + +task copyCommonResources(type: Copy) { + from fileTree(project(":common").file("src/main/resources")) + into file("build/resources/main") +} + +// Put stuff from gradle.properties into the mod info processResources { dependsOn(copyAccessWidener) dependsOn(copyCoreResources) dependsOn(copyCommonResources) + + def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put + def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder + def replaceProperties = [ + version : mod_version, + mod_name : mod_name, + authors : mod_authors, + description : mod_description, + homepage : mod_homepage, + source : mod_source, + issues : mod_issues, + minecraft_version : minecraft_version, + compatible_minecraft_versions: compatible_minecraft_versions, + java_version : java_version + ] + // The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties + //TODO: Make Forge loader version also be relaced with non hardcoded value instead of "[36,42)" + + inputs.properties replaceProperties + replaceProperties.put 'project', project + filesMatching(resourceTargets) { + expand replaceProperties + } + + intoTargets.each { target -> + if (file(target).exists()) { + copy { + from(sourceSets.main.resources) { + include resourceTargets + expand replaceProperties + } + into target + } + } + } } -jar.dependsOn(project(":core").remapJar) -remapSourcesJar.dependsOn(project(":core").remapJar) + shadowJar { dependencies { exclude(dependency("net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}")) @@ -86,6 +182,11 @@ remapJar { } jar { + manifest { + attributes 'Implementation-Title': rootProject.archives_base_name, + 'Implementation-Version': rootProject.mod_version, + 'Main-Class': 'com.seibel.lod.core.JarMain' // When changing the main of the jar change this line + } classifier "dev" } @@ -114,3 +215,79 @@ publishing { // Add repositories to publish to here. } } + +task printConfigurations { + doLast {task -> + println "Project Name: $name configurations:" + configurations.each { + println " $it.name" + } + } +} + +repositories { + mavenCentral() + + // For parchment mappings + maven { url "https://maven.parchmentmc.org" } + + // used to download and compile dependencies from git repos + maven { url 'https://jitpack.io' } + + // For Manifold Preprocessor + maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } + + // Required for importing Modrinth mods + maven { + name = "Modrinth" + url = "https://api.modrinth.com/maven" + content { + includeGroup "maven.modrinth" + } + } + + // Required for importing CursedForge mods + maven { + url "https://www.cursemaven.com" + content { + includeGroup "curse.maven" + } + } + + // These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource + flatDir { + dirs "${rootDir}/mods/fabric" + content { + includeGroup "fabric-mod" + } + } + flatDir { + dirs "${rootDir}/mods/forge" + content { + includeGroup "forge-mod" + } + } +} + +tasks.withType(JavaCompile) { + // Add Manifold Preprocessor +// def excapedMCVersion = rootProject.minecraft_version.replace(".", "_") +// options.compilerArgs += ['-Xplugin:Manifold', "-AMC_VERSION_${excapedMCVersion}"] +// + //options.compilerArgs += ['-deprecation'] + //options.compilerArgs += ['-verbose'] + //options.compilerArgs += ['-Xlint:unchecked'] + //options.compilerArgs += ['-Xdiags:verbose'] + //options.compilerArgs += ['-Xprint'] + //options.compilerArgs += ['-XprintProcessorInfo'] + //options.compilerArgs += ['-XprintRounds'] + + // println options.compilerArgs + + // Set the java version + options.compilerArgs += ['-Xplugin:Manifold'] + options.release = rootProject.java_version as Integer //FIXME: This warning?? + + // TODO: make everything use java 8 + // options.release = 8 // Use Java 8 for everything so back porting is easier? +} diff --git a/gradle.properties b/gradle.properties index 85078cc84..97cade620 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ mod_issues=https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues # Global Plugin versions toml_version=3.6.4 -manifold_version=2022.1.14 +manifold_version=2022.1.15 enabled_platforms=fabric,forge mcVersions=1.16.5,1.17.1,1.18.1,1.18.2,1.19