From 991a6dc772f3f258a8bc080ea0d6697421bf025e Mon Sep 17 00:00:00 2001 From: bombcar Date: Thu, 10 Feb 2022 19:33:30 -0600 Subject: [PATCH] update buildscript, fix mcmod info not displaying --- build.gradle | 100 ++++++++++-------- dependencies.gradle | 6 +- gradle.properties | 12 +-- .../java/codechicken/nei/NEIModContainer.java | 8 +- .../codechicken/nei/asm/NEICorePlugin.java | 2 + src/main/resources/dependencies.info | 6 +- src/main/resources/mcmod.info | 2 +- 7 files changed, 73 insertions(+), 63 deletions(-) diff --git a/build.gradle b/build.gradle index 7b531dc0..3d3fd926 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,14 @@ -//version: 1644194279 +//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 a6690836..32dabfd4 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,7 +1,7 @@ // Add your dependencies here dependencies { - compile("com.github.GTNewHorizons:CodeChickenLib:1.1.5.3:dev") - compile("com.github.GTNewHorizons:CodeChickenCore:1.1.3:dev") - shadowImplementation("org.apache.commons:commons-csv:1.5") + compile('com.github.GTNewHorizons:CodeChickenLib:1.1.5.3:dev') + compile('com.github.GTNewHorizons:CodeChickenCore:1.1.3:dev') + shadowImplementation('org.apache.commons:commons-csv:1.8') } diff --git a/gradle.properties b/gradle.properties index ccea1d59..86965137 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,15 +15,15 @@ autoUpdateBuildScript = false minecraftVersion = 1.7.10 forgeVersion = 10.13.4.1614 -# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you +# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you # restart Minecraft in development. Choose this dependent on your mod: # Do you need consistent player progressing (for example Thaumcraft)? -> Select a name # Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty -developmentEnvironmentUserName = "Developer" +developmentEnvironmentUserName = Developer # Define a source file of your project with: # public static final String VERSION = "GRADLETOKEN_VERSION"; -# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's +# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's # version in @Mod([...], version = VERSION, [...]) # Leave these properties empty to skip individual token replacements replaceGradleTokenInFile = NEIModContainer.java @@ -32,12 +32,12 @@ gradleTokenModName = GRADLETOKEN_MODNAME gradleTokenVersion = GRADLETOKEN_VERSION gradleTokenGroupName = -# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can +# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can # leave this property empty. # Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api apiPackage = -# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/ +# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/ # Example value: mymodid_at.cfg accessTransformersFile = nei_at.cfg @@ -48,7 +48,7 @@ mixinPlugin = # Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail! mixinsPackage = # Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin! -# This parameter is for legacy compatability only +# This parameter is for legacy compatibility only # Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin coreModClass = asm.NEICorePlugin # If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class diff --git a/src/main/java/codechicken/nei/NEIModContainer.java b/src/main/java/codechicken/nei/NEIModContainer.java index 2ad15bd3..553b1954 100644 --- a/src/main/java/codechicken/nei/NEIModContainer.java +++ b/src/main/java/codechicken/nei/NEIModContainer.java @@ -25,10 +25,7 @@ import cpw.mods.fml.common.versioning.VersionRange; import net.minecraft.util.EnumChatFormatting; import java.io.File; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; +import java.util.*; public class NEIModContainer extends DummyModContainer { @@ -46,6 +43,9 @@ public class NEIModContainer extends DummyModContainer modMetadata.name = "GRADLETOKEN_MODNAME"; modMetadata.modId = "GRADLETOKEN_MODID"; modMetadata.version = "GRADLETOKEN_VERSION"; + modMetadata.authorList = Arrays.asList( "ChickenBones", "mitchej123" ); + modMetadata.url = "https://github.com/GTNewHorizons/NotEnoughItems"; + modMetadata.description = "Recipe Viewer, Inventory Manager, Item Spawner, Cheats and more; GTNH Version includes many enhancements."; return modMetadata; } diff --git a/src/main/java/codechicken/nei/asm/NEICorePlugin.java b/src/main/java/codechicken/nei/asm/NEICorePlugin.java index 4e629220..c0c2022b 100644 --- a/src/main/java/codechicken/nei/asm/NEICorePlugin.java +++ b/src/main/java/codechicken/nei/asm/NEICorePlugin.java @@ -4,12 +4,14 @@ import codechicken.core.launch.CodeChickenCorePlugin; import codechicken.lib.asm.ASMInit; import cpw.mods.fml.relauncher.IFMLCallHook; import cpw.mods.fml.relauncher.IFMLLoadingPlugin; +import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion; import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions; import java.io.File; import java.util.Map; @TransformerExclusions(value = {"codechicken.nei.asm"}) +@MCVersion( "1.7.10" ) public class NEICorePlugin implements IFMLLoadingPlugin, IFMLCallHook { public static File location; diff --git a/src/main/resources/dependencies.info b/src/main/resources/dependencies.info index 162ede16..10b6cfe4 100644 --- a/src/main/resources/dependencies.info +++ b/src/main/resources/dependencies.info @@ -1,7 +1,7 @@ { - "repo": "https://github.com/GTNewHorizons/CodeChickenLib/releases/download/1.1.4.1/", - "file": "CodeChickenLib-1.7.10-1.1.4.1.jar", - "dev": "CodeChickenLib-1.7.10-1.1.4.1-dev.jar", + "repo": "https://github.com/GTNewHorizons/CodeChickenLib/releases/download/1.1.5.3/", + "file": "CodeChickenLib-1.7.10-1.1.5.3.jar", + "dev": "CodeChickenLib-1.7.10-1.1.5.3-dev.jar", "class": "codechicken.lib.asm.ASMHelper", "coreLib": true } diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 4435edd3..9a461a9e 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -4,7 +4,7 @@ "name": "${modName}", "version": "${modVersion}", "mcversion": "${minecraftVersion}", - "description": "Recipe Viewer, Inventory Manager, Item Spawner, Cheats and more; GTNH Version includes many ehancements.", + "description": "Recipe Viewer, Inventory Manager, Item Spawner, Cheats and more; GTNH Version includes many enhancements.", "url": "https://github.com/GTNewHorizons/NotEnoughItems", "credits": "Alexandria - original idea", "license": "LGPL-3.0",