summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorUpcraftLP <j-schirra@gmx.de>2019-02-15 22:39:48 +0100
committerUpcraftLP <j-schirra@gmx.de>2019-02-15 22:39:48 +0100
commit8243775b5cfc2108245d8cfb5a7dd1cc2c661e69 (patch)
tree4ddc9e97cd29d19f40be7bcc5171baf4dfe57d73
parent8c0584bbaf15d3c63ba38e35dfc90eae2cd73ecc (diff)
automatically set mod version on export
-rw-r--r--build.gradle22
-rw-r--r--src/main/resources/fabric.mod.json2
2 files changed, 21 insertions, 3 deletions
diff --git a/build.gradle b/build.gradle
index 4815d67..e29d985 100644
--- a/build.gradle
+++ b/build.gradle
@@ -23,6 +23,24 @@ dependencies {
 	modCompile "net.fabricmc:fabric:${project.fabric_version}"
 }
 
+processResources {
+	// this will ensure that this task is re-run when there's a change
+	inputs.property "version", project.version
+
+	// replace stuff in fabric.mod.json, nothing else
+	from(sourceSets.main.resources.srcDirs) {
+		include "fabric.mod.json"
+
+		// add mod metadata
+		expand "version": project.version
+	}
+
+	// copy everything else, thats not the mcmod.info
+	from(sourceSets.main.resources.srcDirs) {
+		exclude "fabric.mod.json"
+	}
+}
+
 // ensure that the encoding is set to UTF-8, no matter what the system default is
 // this fixes some edge cases with special characters not displaying correctly
 // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
@@ -34,7 +52,7 @@ tasks.withType(JavaCompile) {
 // if it is present.
 // If you remove this task, sources will not be generated.
 task sourcesJar(type: Jar, dependsOn: classes) {
-	classifier = 'sources'
+	classifier = "sources"
 	from sourceSets.main.allSource
 }
 
@@ -51,7 +69,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
 if (JavaVersion.current().isJava8Compatible()) {
 	allprojects {
 		tasks.withType(Javadoc) {
-			options.addStringOption('Xdoclint:none', '-quiet')
+			options.addStringOption("Xdoclint:none", "-quiet")
 		}
 	}
 }
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
index 180f60b..4b9af9f 100644
--- a/src/main/resources/fabric.mod.json
+++ b/src/main/resources/fabric.mod.json
@@ -2,7 +2,7 @@
   "id": "modid",
   "name": "Example Mod",
   "description": "This is an example description! Tell everyone what your mod is about!",
-  "version": "1.0.0",
+  "version": "${version}",
   "side": "universal",
   "initializers": [
     "net.fabricmc.example.ExampleMod"