Merge branch 'build-script-update-check' into buildscript-versioning-and-migration-zip

This commit is contained in:
Johann Bernhardt committed 2021-11-13 22:33:01 +01:00
commit 549859df01
3 files changed
+114 -4

No files matched your search

+10
View File
@@ -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/docs/FAQ.md). If that doesn't help, please open an issue.
### Getting started
Creating mod from scratch:
@@ -50,6 +54,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, but 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.
@@ -59,6 +65,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!
+91 -4
View File
@@ -47,6 +47,91 @@ idea {
}
}
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")
}
}
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)
@@ -55,16 +140,14 @@ 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
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"
@@ -85,6 +168,10 @@ minecraft {
}
}
if(file("addon.gradle").exists()) {
apply from: "addon.gradle"
}
apply from: 'repositories.gradle'
configurations {
+13
View File
@@ -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`.