From d2974b06a60ce96c84d672dc65c4216c694132c1 Mon Sep 17 00:00:00 2001 From: Johann Bernhardt Date: Sun, 7 Nov 2021 13:07:16 +0100 Subject: [PATCH 1/7] Jenkins version string fix --- build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle b/build.gradle index 46f5232..b1c6ec1 100644 --- a/build.gradle +++ b/build.gradle @@ -54,6 +54,8 @@ configurations.all { System.setProperty("org.gradle.internal.http.socketTimeout", 120000 as String) } +// Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version +'git config core.fileMode false'.execute() // Pulls version from git tag version = minecraftVersion + "-" + gitVersion() group = modGroup From ad7153900c10be5f01848f95ae74de2292180107 Mon Sep 17 00:00:00 2001 From: Johann Bernhardt Date: Fri, 12 Nov 2021 11:45:12 +0100 Subject: [PATCH 2/7] Added custom gradle command support --- README.md | 4 ++++ build.gradle | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 3bef3f5..fd70697 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,10 @@ Take a look at the examples in [`com.myname.mymodid.mixinplugin.*`](https://gith Check out the [`example-mixins`](https://github.com/SinTh0r4s/ExampleMod1.7.10/tree/example-mixins) brach for a working example! +### Advanced + +If your project requires custom gradle commands you may add a `addon.gradle` to your project. It will be added automatically to the build script. Although we recommend against it, it is sometimes required. When in doubt, feel free to ask us about it. You may break future updates of this build system! + ### Feedback wanted If you tried out this build script we would love to head your opinion! Is there any feature missing for you? Did something not work? Please open an issue and we will try to resolve it asap! diff --git a/build.gradle b/build.gradle index b1c6ec1..e97b1dd 100644 --- a/build.gradle +++ b/build.gradle @@ -86,6 +86,10 @@ minecraft { } } +if(file("addon.gradle").exists()) { + apply from: "addon.gradle" +} + apply from: 'repositories.gradle' configurations { From 7a86c872ddaffcb3c86a825c6c68b7d6d40e9308 Mon Sep 17 00:00:00 2001 From: Johann Bernhardt Date: Fri, 12 Nov 2021 13:06:20 +0100 Subject: [PATCH 3/7] Added parameter checks --- build.gradle | 77 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index e97b1dd..09490ee 100644 --- a/build.gradle +++ b/build.gradle @@ -46,6 +46,79 @@ idea { } } + +if(JavaVersion.current() != JavaVersion.VERSION_1_8) { + throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current()) +} + +def checkPropertyExsists(String propertyName) { + if (project.hasProperty(propertyName) == false) { + throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/gradle.properties") + } +} + +checkPropertyExsists("modName") +checkPropertyExsists("modId") +checkPropertyExsists("modGroup") +checkPropertyExsists("minecraftVersion") +checkPropertyExsists("forgeVersion") +checkPropertyExsists("replaceGradleTokenInFile") +checkPropertyExsists("gradleTokenModId") +checkPropertyExsists("gradleTokenModName") +checkPropertyExsists("gradleTokenVersion") +checkPropertyExsists("gradleTokenGroupName") +checkPropertyExsists("apiPackage") +checkPropertyExsists("accessTransformersFile") +checkPropertyExsists("usesMixins") +checkPropertyExsists("mixinPlugin") +checkPropertyExsists("mixinsPackage") +checkPropertyExsists("coreModClass") +checkPropertyExsists("containsMixinsAndOrCoreModOnly") +checkPropertyExsists("usesShadowedDependencies") +checkPropertyExsists("developmentEnvironmentUserName") + +String targetPackage = "src/main/java/" + modGroup.toString().replaceAll("\\.", "/") +if(new File(targetPackage).exists() == false) { + throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackage) +} + +if(apiPackage) { + targetPackage = "src/main/java/" + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + if(new File(targetPackage).exists() == false) { + throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackage) + } +} + +if(accessTransformersFile) { + targetPackage = "src/main/resources/META-INF/" + accessTransformersFile + if(new File(targetPackage).exists() == false) { + throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetPackage) + } +} + +if(usesMixins.toBoolean()) { + if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) { + throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!") + } + + targetPackage = "src/main/java/" + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/") + if(new File(targetPackage).exists() == false) { + throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackage) + } + + String targetFile = "src/main/java/" + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java" + if(new File(targetFile).exists() == false) { + throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFile) + } +} + +if(coreModClass) { + String targetFile = "src/main/java/" + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java" + if(new File(targetFile).exists() == false) { + throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFile) + } +} + configurations.all { resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS) @@ -62,10 +135,6 @@ group = modGroup archivesBaseName = modId minecraft { - if(JavaVersion.current() != JavaVersion.VERSION_1_8) { - throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current()) - } - version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion runDir = "run" From cb1aae78b8e9611cdc4590e3b57a730b7eb631e5 Mon Sep 17 00:00:00 2001 From: Johann Bernhardt Date: Fri, 12 Nov 2021 13:21:20 +0100 Subject: [PATCH 4/7] Add FAQ and access transformer warning --- FAQ.md | 13 +++++++++++++ README.md | 6 ++++++ 2 files changed, 19 insertions(+) create mode 100644 FAQ.md diff --git a/FAQ.md b/FAQ.md new file mode 100644 index 0000000..d5c950d --- /dev/null +++ b/FAQ.md @@ -0,0 +1,13 @@ +# Things we cannot protect you from (yet) + +### Select an mcp conf dir for the deobfuscator + +You may or may not run into this popup. For now, the only solution is to point the deopfuscator into the right direction. + +![](http://i.imgur.com/gzBMLrr.png) + +Solution: Point it to `~/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.10-10.13.4.1614-1.7.10/unpacked/conf`. On Windows, please use `%USERPROFILE%/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.10-10.13.4.1614-1.7.10/unpacked/conf`. + +### Could not find :forgeBin:1.7.10-10.13.4.1614-1.7.10 + +Run the gradle task `setupDecompWorkspace`. \ No newline at end of file diff --git a/README.md b/README.md index fd70697..42000ee 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ An example mod for Minecraft 1.7.10 with Forge focussed on a stable, updatable s We had our fair share in struggles with build scripts for Minecraft Forge. There are quite a few pitfalls from non-obvious error messages. This Example Project provides you a build system you can adapt to over 90% of Minecraft Forge mods and can easily be updated if need be. +### Help! I'm stuck! + +We all have been there! Check out our [FAQ](https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/FAQ.md). If that doesn't help, please open an issue. + ### Getting started Creating mod from scratch: @@ -49,6 +53,8 @@ You may activate Forge's Access Transformers by defining a configuration file in Check out the [`example-access-transformers`](https://github.com/SinTh0r4s/ExampleMod1.7.10/tree/example-access-transformers) brach for a working example! +__Warning:__ Access Transformers are bugged and will deny you any sources for the decompiled minecraft! Your development environment will still work, you might face some inconveniences. For example, IntelliJ will not permit searches in dependencies without attached sources. + ### Mixins Mixins are usually used to modify vanilla or mod/library in runtime without having to change source code. For example, redirect a call, change visibility or make class implement your interface. It's an advanced topic and most mods don't need to do that. From 8e64220124e272b053965e881d201e9204f65937 Mon Sep 17 00:00:00 2001 From: Johann Bernhardt Date: Fri, 12 Nov 2021 13:24:46 +0100 Subject: [PATCH 5/7] Move FAQ to docs --- README.md | 2 +- FAQ.md => docs/FAQ.md | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename FAQ.md => docs/FAQ.md (100%) diff --git a/README.md b/README.md index 42000ee..a94c447 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ We had our fair share in struggles with build scripts for Minecraft Forge. There ### Help! I'm stuck! -We all have been there! Check out our [FAQ](https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/FAQ.md). If that doesn't help, please open an issue. +We all have been there! Check out our [FAQ](https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/docs/FAQ.md). If that doesn't help, please open an issue. ### Getting started diff --git a/FAQ.md b/docs/FAQ.md similarity index 100% rename from FAQ.md rename to docs/FAQ.md From 21883feeab1bbade4a52509447ccb6ec17e37593 Mon Sep 17 00:00:00 2001 From: Johann Bernhardt Date: Fri, 12 Nov 2021 13:25:31 +0100 Subject: [PATCH 6/7] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a94c447..f4d540a 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ You may activate Forge's Access Transformers by defining a configuration file in Check out the [`example-access-transformers`](https://github.com/SinTh0r4s/ExampleMod1.7.10/tree/example-access-transformers) brach for a working example! -__Warning:__ Access Transformers are bugged and will deny you any sources for the decompiled minecraft! Your development environment will still work, you might face some inconveniences. For example, IntelliJ will not permit searches in dependencies without attached sources. +__Warning:__ Access Transformers are bugged and will deny you any sources for the decompiled minecraft! Your development environment will still work, but you might face some inconveniences. For example, IntelliJ will not permit searches in dependencies without attached sources. ### Mixins From d4a4bdbd6dd1858713feae7890989ca8d289c04f Mon Sep 17 00:00:00 2001 From: Johann Bernhardt Date: Fri, 12 Nov 2021 13:49:09 +0100 Subject: [PATCH 7/7] Draft for potential build script update hint --- build.gradle | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/build.gradle b/build.gradle index 09490ee..a03073c 100644 --- a/build.gradle +++ b/build.gradle @@ -51,6 +51,18 @@ if(JavaVersion.current() != JavaVersion.VERSION_1_8) { throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current()) } +def checkForUpdate() { + Thread.start { + Map parameters = [ "connectTimeout" : 2000, "readTimeout": 2000 ] + String currentBuildScript = new File("build.gradle").getText() + String availableBuildScript = new URL("https://raw.githubusercontent.com/SinTh0r4s/ExampleMod1.7.10/main/build.gradle").newInputStream(parameters).getText() + if (availableBuildScript.equals("") == false && currentBuildScript.equals(availableBuildScript) == false) { + println("Build script update available! Check https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/build.gradle"); + } + } +} +checkForUpdate() + def checkPropertyExsists(String propertyName) { if (project.hasProperty(propertyName) == false) { throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/gradle.properties")