From 979957a4c0af95e388fec80fbf062ef6418ba248 Mon Sep 17 00:00:00 2001 From: glowredman <35727266+glowredman@users.noreply.github.com> Date: Sat, 12 Feb 2022 14:38:56 +0100 Subject: [PATCH] Make Forestry a soft-dependency (#55) * Update Buildscript * Only load Forestry Farmer if Forestry is installed --- build.gradle | 100 ++++++++++-------- dependencies.gradle | 31 +++--- .../enderio/machine/farm/FarmersRegistry.java | 7 +- 3 files changed, 70 insertions(+), 68 deletions(-) diff --git a/build.gradle b/build.gradle index 4f54c87f..3d3fd926 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,14 @@ -//version: 1643844119 +//version: 1644510936 /* DO NOT CHANGE THIS FILE! Also, you may replace this file at any time if there is an update available. Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates. - */ +*/ +import org.gradle.internal.logging.text.StyledTextOutput +import org.gradle.internal.logging.text.StyledTextOutputFactory +import org.gradle.internal.logging.text.StyledTextOutput.Style import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar @@ -15,20 +18,20 @@ import java.util.concurrent.TimeUnit buildscript { repositories { maven { - name = "forge" - url = "https://maven.minecraftforge.net" + name 'forge' + url 'https://maven.minecraftforge.net' } maven { - name = "sonatype" - url = "https://oss.sonatype.org/content/repositories/snapshots/" + name 'sonatype' + url 'https://oss.sonatype.org/content/repositories/snapshots/' } maven { - name = "Scala CI dependencies" - url = "https://repo1.maven.org/maven2/" + name 'Scala CI dependencies' + url 'https://repo1.maven.org/maven2/' } maven { - name = "jitpack" - url = "https://jitpack.io" + name 'jitpack' + url 'https://jitpack.io' } } dependencies { @@ -37,21 +40,24 @@ buildscript { } plugins { + id 'java-library' id 'idea' id 'eclipse' id 'scala' + id 'maven-publish' id('org.jetbrains.kotlin.jvm') version ('1.6.10') apply false id('org.ajoberstar.grgit') version('4.1.1') id('com.github.johnrengelman.shadow') version('4.0.4') id('com.palantir.git-version') version('0.13.0') apply false id('de.undercouch.download') version('5.0.1') - id('maven-publish') } if (project.file('.git/HEAD').isFile()) { apply plugin: 'com.palantir.git-version' } +def out = services.get(StyledTextOutputFactory).create("an-output") + apply plugin: 'forge' def projectJavaVersion = JavaLanguageVersion.of(8) @@ -168,7 +174,7 @@ try { 'git config core.fileMode false'.execute() } catch (Exception e) { - logger.error("\u001B[31mgit isn't installed at all\u001B[0m") + out.style(Style.Failure).println("git isn't installed at all") } // Pulls version first from the VERSION env and then git tag @@ -178,9 +184,11 @@ try { identifiedVersion = versionOverride == null ? gitVersion() : versionOverride } catch (Exception e) { - logger.error("\n\u001B[1;31mThis mod must be version controlled by Git AND the repository must provide at least one tag,\n" + - "or the VERSION override must be set! \u001B[32m(Don't download from GitHub using the ZIP option, instead\n" + - "clone the repository, see\u001B[33m https://gtnh.miraheze.org/wiki/Development \u001B[32mfor details.)\u001B[0m\n"); + out.style(Style.Failure).text( + 'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' + + 'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' + + 'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)' + ) versionOverride = 'NO-GIT-TAG-SET' identifiedVersion = versionOverride } @@ -188,8 +196,7 @@ version = minecraftVersion + '-' + identifiedVersion String modVersion = identifiedVersion if( identifiedVersion.equals(versionOverride) ) { - logger.error('\u001B[31m\u001B[7mWe hope you know what you\'re doing using\u001B[0m\u001B[1;34m ' + modVersion + '\u001B[0m\n'); - logger.error('\7\u001B[31mGoing to blindly try to use\u001B[1;34m ' + modVersion + '\u001B[0m\u001B[31m, this probably won\'t work the way you expect!!\u001B[0m\n'); + out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7') } group = modGroup @@ -262,36 +269,36 @@ configurations { repositories { maven { - name = "Overmind forge repo mirror" - url = "https://gregtech.overminddl1.com/" + name 'Overmind forge repo mirror' + url 'https://gregtech.overminddl1.com/' } if(usesMixins.toBoolean()) { maven { - name = "sponge" - url = "https://repo.spongepowered.org/repository/maven-public" + name 'sponge' + url 'https://repo.spongepowered.org/repository/maven-public' } maven { - url = "https://jitpack.io" + url 'https://jitpack.io' } } } dependencies { if(usesMixins.toBoolean()) { - annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3") - annotationProcessor("com.google.guava:guava:24.1.1-jre") - annotationProcessor("com.google.code.gson:gson:2.8.6") - annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT") + annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3') + annotationProcessor('com.google.guava:guava:24.1.1-jre') + annotationProcessor('com.google.code.gson:gson:2.8.6') + annotationProcessor('org.spongepowered:mixin:0.8-SNAPSHOT') // using 0.8 to workaround a issue in 0.7 which fails mixin application - compile("com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH") { + compile('com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH') { // Mixin includes a lot of dependencies that are too up-to-date - exclude module: "launchwrapper" - exclude module: "guava" - exclude module: "gson" - exclude module: "commons-io" - exclude module: "log4j-core" + exclude module: 'launchwrapper' + exclude module: 'guava' + exclude module: 'gson' + exclude module: 'commons-io' + exclude module: 'log4j-core' } - compile("com.github.GTNewHorizons:SpongeMixins:1.5.0") + compile('com.github.GTNewHorizons:SpongeMixins:1.5.0') } } @@ -411,7 +418,7 @@ processResources from(sourceSets.main.resources.srcDirs) { include 'mcmod.info' - // replace version and mcversion + // replace modVersion and minecraftVersion expand "minecraftVersion": project.minecraft.version, "modVersion": modVersion, "modId": modId, @@ -422,7 +429,7 @@ processResources from refMap } - // copy everything else, thats not the mcmod.info + // copy everything else that's not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' } @@ -539,8 +546,6 @@ tasks.withType(GenerateModuleMetadata) { enabled = false } - -// publishing publishing { publications { maven(MavenPublication) { @@ -561,13 +566,16 @@ publishing { // Using the identified version, not project.version as it has the prepended 1.7.10 version = System.getenv("RELEASE_VERSION") ?: identifiedVersion - // Remove all non GTNH deps here. - // Original intention was to remove an invalid forgeBin being generated without a groupId (mandatory), but - // it also removes all of the MC deps + // remove extra garbage from who knows where pom.withXml { + def badPomGroup = ['net.minecraft', 'com.google.code.findbugs', 'org.ow2.asm', 'com.typesafe.akka', 'com.typesafe', 'org.scala-lang', + 'org.scala-lang.plugins', 'net.sf.jopt-simple', 'lzma', 'com.mojang', 'org.apache.commons', 'org.apache.httpcomponents', + 'commons-logging', 'java3d', 'net.sf.trove4j', 'com.ibm.icu', 'com.paulscode', 'io.netty', 'com.google.guava', + 'commons-io', 'commons-codec', 'net.java.jinput', 'net.java.jutils', 'com.google.code.gson', 'org.apache.logging.log4j', + 'org.lwjgl.lwjgl', 'tv.twitch', ''] Node pomNode = asNode() pomNode.dependencies.'*'.findAll() { - it.groupId.text() != 'com.github.GTNewHorizons' + badPomGroup.contains(it.groupId.text()) }.each() { it.parent().remove(it) } @@ -599,7 +607,7 @@ if (isNewBuildScriptVersionAvailable(projectDir.toString())) { if (autoUpdateBuildScript.toBoolean()) { performBuildScriptUpdate(projectDir.toString()) } else { - println("Build script update available! Run 'gradle updateBuildScript'") + out.style(Style.SuccessHeader).println("Build script update available! Run 'gradle updateBuildScript'") } } @@ -611,7 +619,7 @@ boolean performBuildScriptUpdate(String projectDir) { if (isNewBuildScriptVersionAvailable(projectDir)) { def buildscriptFile = getFile("build.gradle") availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } } - print("Build script updated. Please REIMPORT the project or RESTART your IDE!") + out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!") return true } return false @@ -673,7 +681,7 @@ def deobf(String sourceURL) { } } -// The method above is to be prefered. Use this method if the filename is not at the end of the URL. +// The method above is to be preferred. Use this method if the filename is not at the end of the URL. def deobf(String sourceURL, String fileName) { String cacheDir = System.getProperty("user.home") + "/.gradle/caches/" String bon2Dir = cacheDir + "forge_gradle/deobf" @@ -685,14 +693,14 @@ def deobf(String sourceURL, String fileName) { return files(deobfFile) } - download { + download.run { src 'https://github.com/GTNewHorizons/BON2/releases/download/2.5.0/BON2-2.5.0.CUSTOM-all.jar' dest bon2File quiet true overwrite false } - download { + download.run { src sourceURL dest obfFile quiet true diff --git a/dependencies.gradle b/dependencies.gradle index d243dd4e..88fc7843 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -2,50 +2,45 @@ dependencies { compile("com.github.GTNewHorizons:CodeChickenLib:1.1.5.3:dev") - compile("com.github.GTNewHorizons:CodeChickenCore:1.1.3:dev") + compile("com.github.GTNewHorizons:CodeChickenCore:1.1.4:dev") compile("com.github.GTNewHorizons:EnderCore:0.2.6:dev") compile("com.github.GTNewHorizons:ForestryMC:4.4.5:dev") - compile("com.github.GTNewHorizons:NotEnoughItems:2.2.5-GTNH:dev") - compile("curse.maven:cofh-lib-220333:2388748") - compile("com.github.GTNewHorizons:BuildCraft:7.1.26:dev") + compile("com.github.GTNewHorizons:NotEnoughItems:2.2.7-GTNH:dev") + compile("curse.maven:cofh-lib-220333:2388748") // https://www.curseforge.com/minecraft/mc-mods/cofh-lib/files/2388748 + compile("com.github.GTNewHorizons:BuildCraft:7.1.27:dev") shadowImplementation("cglib:cglib-nodep:3.3.0") - compileOnly("com.github.GTNewHorizons:waila:1.5.18:api") { + compileOnly("com.github.GTNewHorizons:waila:1.5.19:api") { transitive = false } - compileOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-75-GTNH:api") { + compileOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-76-GTNH:api") { transitive = false } compileOnly("com.github.GTNewHorizons:Baubles:1.0.1.14:dev") { transitive = false } - compileOnly("com.github.GTNewHorizons:Railcraft:9.13.5:api") { + compileOnly("com.github.GTNewHorizons:Railcraft:9.13.6:api") { transitive = false } - compileOnly("com.github.GTNewHorizons:StorageDrawers:1.11.11-GTNH:api") { + compileOnly("com.github.GTNewHorizons:StorageDrawers:1.11.13-GTNH:api") { transitive = false } compileOnly("com.github.GTNewHorizons:Chisel:2.10.8-GTNH:dev") { transitive = false } - compileOnly("com.github.GTNewHorizons:OpenComputers:1.7.5.21-GTNH:api") { + compileOnly("com.github.GTNewHorizons:OpenComputers:1.7.5.23-GTNH:api") { transitive = false } - - compileOnly("curse.maven:minefactory-reloaded-66672:2366150") { - transitive = false - } - compileOnly("curse.maven:computercraft-67504:2269339") { // https://www.curseforge.com/minecraft/mc-mods/computercraft/files/2269339 + compileOnly("curse.maven:minefactory-reloaded-66672:2366150") { // https://www.curseforge.com/minecraft/mc-mods/minefactory-reloaded/files/2366150 transitive = false } compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") { transitive = false } - compileOnly("curse.maven:mekanism-268560:2475797") { // https://www.curseforge.com/minecraft/mc-mods/mekanism/files/2475797 - transitive = false - } compileOnly("curse.maven:ee3-65509:2305023") { // https://www.curseforge.com/minecraft/mc-mods/ee3/files/2305023 transitive = false } - compileOnly files("dependencies/immibis-microblocks-59.1.2.jar") + compileOnly(deobf("https://media.forgecdn.net/files/2269/339/ComputerCraft1.75.jar")) // https://www.curseforge.com/minecraft/mc-mods/computercraft/files/2269339 + compileOnly(deobf("https://s3.amazonaws.com/aidancbrady/mekanism/281-recommended/Mekanism-1.7.10-9.1.0.281.jar")) // https://aidancbrady.com/mekanism/download/ + compileOnly deobf("https://immibis.com/mcmoddl/files/immibis-microblocks-59.1.2.jar") } diff --git a/src/main/java/crazypants/enderio/machine/farm/FarmersRegistry.java b/src/main/java/crazypants/enderio/machine/farm/FarmersRegistry.java index a5c2663d..a2f42d31 100644 --- a/src/main/java/crazypants/enderio/machine/farm/FarmersRegistry.java +++ b/src/main/java/crazypants/enderio/machine/farm/FarmersRegistry.java @@ -1,8 +1,5 @@ package crazypants.enderio.machine.farm; -import java.util.Iterator; -import java.util.regex.Pattern; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -38,7 +35,9 @@ public final class FarmersRegistry { addIC2(); addThaumcraft(); addFlowers(); - ForestryFarmer.init(); + if (Loader.isModLoaded("Forestry")) { + ForestryFarmer.init(); + } FarmersCommune.joinCommune(new StemFarmer(Blocks.reeds, new ItemStack(Items.reeds))); FarmersCommune.joinCommune(new StemFarmer(Blocks.cactus, new ItemStack(Blocks.cactus)));