aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalker Selby <git@walkerselby.com>2023-05-12 11:32:40 -0700
committernea <nea@nea.moe>2023-05-25 02:24:37 +0200
commit7e8fa83e5afc0b21c96b91bbe87f39751e841bf7 (patch)
treefc0068c473beae7a9db766e8caf87bc074bf0769
parentcc5c1a8d1cb3e1042908d59e17199ffadfff0fc7 (diff)
downloadforge1.8.9template-7e8fa83e5afc0b21c96b91bbe87f39751e841bf7.tar.gz
forge1.8.9template-7e8fa83e5afc0b21c96b91bbe87f39751e841bf7.tar.bz2
forge1.8.9template-7e8fa83e5afc0b21c96b91bbe87f39751e841bf7.zip
Add constants to buildscript to allow easier setup
Refactor to create constants for common values to be replaced Signed-off-by: Walker Selby <git@walkerselby.com>
-rw-r--r--README.md10
-rw-r--r--build.gradle.kts34
-rw-r--r--gradle.properties3
-rw-r--r--src/main/resources/mcmod.info30
4 files changed, 51 insertions, 26 deletions
diff --git a/README.md b/README.md
index d61b6f5..de9e3bd 100644
--- a/README.md
+++ b/README.md
@@ -2,10 +2,14 @@
**For other templates, do check out the [other branches of this repository](https://github.com/romangraef/Forge1.8.9Template/branches/all)**
-To get started, clone this repository and replace all references to `examplemod` or `com.example` with your own names.
+To get started, clone this repository.
+In `build.gradle.kts`, replace the values of `baseGroup` and `group` with your own names.
+In `settings.gradle.kts` change `rootProject.name` to your desired mod id.
+
+The `com.example` package needs to be renamed to match the value of `baseGroup`.
If you don't want mixins (which allow for modifying vanilla code), then you can remove the references to mixins from
-the `build.gradle.kts`, delete the `mixins.examplemod.json` and the `com.example.mixin` package.
+the `build.gradle.kts` at the lines specified with comments and the `com.example.mixin` package.
This project uses [DevAuth](https://github.com/DJtheRedstoner/DevAuth) per default, so you can log in using your real
minecraft account. If you don't need that, you can remove it from the buildscript.
@@ -15,7 +19,7 @@ from [here](https://adoptium.net/temurin/releases) (or use your own downloads).
When you import your project into IntelliJ, you need to set the gradle jvm to the Java 17 JDK in the gradle tab, and the
Project SDK to the Java 1.8 JDK. Then click on the sync button in IntelliJ, and it should create a run task
-called `Minecraft Client`. If it doesn't then try relaunching your IntelliJ. **Warning for Mac users**: You might have to remove the `-XStartOnFirstThread` vm argument from your run configuration. In the future, that should be handled by the plugin, but for now you'll probably have to do that manually.
+called `Minecraft Client`. If it doesn't then try relaunching your IntelliJ. **Warning for Mac users**: You might have to remove the `-XStartOnFirstThread` vm argument from your run configuration. In the future, that should be handled by the plugin, but for now you'll probably have to do that manually.
To export your project, run the `gradle build` task, and give other people the
file `build/libs/<modid>-<version>.jar`. Ignore the jars in the `build/badjars` folder. Those are intermediary jars that
diff --git a/build.gradle.kts b/build.gradle.kts
index c5eb641..3f514b2 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -6,8 +6,13 @@ plugins {
id("com.github.johnrengelman.shadow") version "7.1.2"
}
-group = "com.example.archloomtemplate"
-version = "1.0.0"
+//Constants:
+
+val baseGroup: String by project
+val mcVersion: String by project
+val version: String by project
+val mixinGroup = "$baseGroup.mixin"
+val modid = rootProject.name
// Toolchains:
java {
@@ -23,17 +28,17 @@ loom {
property("mixin.debug", "true")
property("asmhelper.verbose", "true")
arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
- arg("--mixin", "mixins.examplemod.json")
+ arg("--mixin", "mixins.$modid.json")
}
}
forge {
pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
// If you don't want mixins, remove this lines
- mixinConfig("mixins.examplemod.json")
+ mixinConfig("mixins.$modid.json")
}
// If you don't want mixins, remove these lines
mixin {
- defaultRefmapName.set("mixins.examplemod.refmap.json")
+ defaultRefmapName.set("mixins.$modid.refmap.json")
}
}
@@ -77,15 +82,28 @@ tasks.withType(JavaCompile::class) {
}
tasks.withType(Jar::class) {
- archiveBaseName.set("examplemod")
+ archiveBaseName.set(modid)
manifest.attributes.run {
this["FMLCorePluginContainsFMLMod"] = "true"
this["ForceLoadAsMod"] = "true"
// If you don't want mixins, remove these lines
this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
- this["MixinConfigs"] = "mixins.examplemod.json"
+ this["MixinConfigs"] = "mixins.$modid.json"
+ }
+}
+
+tasks.processResources {
+ inputs.property("version", project.version)
+ inputs.property("mcversion", mcVersion)
+ inputs.property("modid", modid)
+ inputs.property("mixinGroup", mixinGroup)
+
+ filesMatching(listOf("mcmod.info", "mixins.$modid.json")) {
+ expand(inputs.properties)
}
+
+ rename("(.+_at.cfg)", "META-INF/$1")
}
@@ -111,7 +129,7 @@ tasks.shadowJar {
}
// If you want to include other dependencies and shadow them, you can relocate them in here
- fun relocate(name: String) = relocate(name, "com.examplemod.deps.$name")
+ fun relocate(name: String) = relocate(name, "$baseGroup.deps.$name")
}
tasks.assemble.get().dependsOn(tasks.remapJar)
diff --git a/gradle.properties b/gradle.properties
index 7a79fe1..373da25 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,2 +1,5 @@
loom.platform=forge
org.gradle.jvmargs=-Xmx2g
+baseGroup = com.example
+mcVersion = 1.8.9
+version = 1.0.0 \ No newline at end of file
diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info
index 7b1a26b..e1f8be1 100644
--- a/src/main/resources/mcmod.info
+++ b/src/main/resources/mcmod.info
@@ -1,18 +1,18 @@
[
{
- "modid": "examplemod",
- "name": "Xample Mod",
- "description": "A mod that is used as an example.",
- "version": "1.0.0",
- "mcversion": "1.8.9",
- "url": "https://github.com/romangraef/Forge1.8.9Template/",
- "updateUrl": "",
- "authorList": [
- "You"
- ],
- "credits": "",
- "logoFile": "",
- "screenshots": [],
- "dependencies": []
+ "modid": "${modid}",
+ "name": "Xample Mod",
+ "description": "A mod that is used as an example.",
+ "version": "${version}",
+ "mcversion": "1.8.9",
+ "url": "https://github.com/romangraef/Forge1.8.9Template/",
+ "updateUrl": "",
+ "authorList": [
+ "You"
+ ],
+ "credits": "",
+ "logoFile": "",
+ "screenshots": [],
+ "dependencies": []
}
-]
+] \ No newline at end of file