summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorModmuss50 <modmuss50@gmail.com>2019-02-16 00:17:56 +0000
committerGitHub <noreply@github.com>2019-02-16 00:17:56 +0000
commitb83fbda9e50f141336a47818cd6b1b3de34d413f (patch)
treed4066b479ff350e8d2f98abca538bf5367dc3998
parent2931e41b5a63d117abd5827480b5856cdd7b8d7e (diff)
parente7fad09f14f117879f94d9b3b18e53b921572c8f (diff)
Merge pull request #7 from UpcraftLP/gradle-update
gradle configuration update
-rw-r--r--build.gradle71
-rw-r--r--gradle.properties19
-rw-r--r--src/main/resources/fabric.mod.json2
3 files changed, 80 insertions, 12 deletions
diff --git a/build.gradle b/build.gradle
index 88a48e5..0c38eca 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,29 +1,82 @@
 plugins {
 	id 'fabric-loom' version '0.2.0-SNAPSHOT'
+	id 'maven-publish'
 }
 
-sourceCompatibility = 1.8
-targetCompatibility = 1.8
+sourceCompatibility = JavaVersion.VERSION_1_8
+targetCompatibility = JavaVersion.VERSION_1_8
 
-archivesBaseName = "modid"
-version = "1.0.0"
+archivesBaseName = project.archives_base_name
+version = project.mod_version
+group = project.maven_group
 
 minecraft {
 }
 
 dependencies {
-	minecraft "com.mojang:minecraft:19w06a"
-	mappings "net.fabricmc:yarn:19w06a.3"
-	modCompile "net.fabricmc:fabric-loader:0.3.5.106"
+	//to change the versions see the gradle.properties file
+	minecraft "com.mojang:minecraft:${project.minecraft_version}"
+	mappings "net.fabricmc:yarn:${project.yarn_mappings}"
+	modCompile "net.fabricmc:fabric-loader:${project.loader_version}"
 
 	// Fabric API. This is technically optional, but you probably want it anyway.
-	modCompile "net.fabricmc:fabric:0.2.0.91"
+	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
+tasks.withType(JavaCompile) {
+	options.encoding = "UTF-8"
 }
 
 // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
 // 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
 }
+
+jar {
+	from "LICENSE"
+}
+
+// configure the maven publication
+publishing {
+	publications {
+		mavenJava(MavenPublication) {
+			// add all the jars that should be included when publishing to maven
+			artifact(jar) {
+				builtBy remapJar
+			}
+			artifact(sourcesJar) {
+				builtBy remapSourcesJar
+			}
+		}
+	}
+
+	// select the repositories you want to publish to
+	repositories {
+		// uncomment to publish to the local maven
+		// mavenLocal()
+	}
+}
diff --git a/gradle.properties b/gradle.properties
index d8e54c1..5e987a0 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,2 +1,17 @@
-#Done to increase the memory available to gradle.
-org.gradle.jvmargs=-Xmx1G
\ No newline at end of file
+# Done to increase the memory available to gradle.
+org.gradle.jvmargs=-Xmx1G
+
+# Fabric Properties
+	# check these on https://fabricmc.net/use
+	minecraft_version=19w07a
+	yarn_mappings=19w07a.6
+	loader_version=0.3.6.107
+
+# Mod Properties
+	mod_version = 1.0.0
+	maven_group = net.fabricmc
+	archives_base_name = fabric-example-mod
+
+# Dependencies
+	# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric
+	fabric_version=0.2.1.94
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"