From 51bee1baf0edd9c536b504aeee1ae6e3e44b474d Mon Sep 17 00:00:00 2001 From: UpcraftLP Date: Fri, 15 Feb 2019 21:52:41 +0100 Subject: [PATCH 1/9] use constants for source/target compatibility levels --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 88a48e5..a698bd7 100644 --- a/build.gradle +++ b/build.gradle @@ -2,8 +2,8 @@ plugins { id 'fabric-loom' version '0.2.0-SNAPSHOT' } -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 archivesBaseName = "modid" version = "1.0.0" From 8bbfcdcb4b36b59fe1320a2e48378c3001ba42f4 Mon Sep 17 00:00:00 2001 From: UpcraftLP Date: Fri, 15 Feb 2019 21:54:29 +0100 Subject: [PATCH 2/9] move properties out of the main buildscript --- build.gradle | 13 +++++++------ gradle.properties | 18 ++++++++++++++++-- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index a698bd7..7471ac1 100644 --- a/build.gradle +++ b/build.gradle @@ -5,19 +5,20 @@ plugins { 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 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}" } // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task diff --git a/gradle.properties b/gradle.properties index d8e54c1..6a5fbb2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,16 @@ -#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://fabric.asie.pl/use + minecraft_version=19w07a + yarn_mappings=19w07a.6 + loader_version=0.3.6.107 + +# Mod Properties + mod_version = 1.0.0 + 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 From 133913f4204fd0cb8241e3f4c69017ca20963e98 Mon Sep 17 00:00:00 2001 From: UpcraftLP Date: Fri, 15 Feb 2019 21:55:33 +0100 Subject: [PATCH 3/9] encoding fix for special characters --- build.gradle | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build.gradle b/build.gradle index 7471ac1..2d316c2 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,13 @@ dependencies { modCompile "net.fabricmc:fabric:${project.fabric_version}" } +// 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. From 682afc73a4e652100672f9db1a649108d2205b89 Mon Sep 17 00:00:00 2001 From: UpcraftLP Date: Fri, 15 Feb 2019 21:56:50 +0100 Subject: [PATCH 4/9] add javadoc task and maven-publish plugin --- build.gradle | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/build.gradle b/build.gradle index 2d316c2..377c613 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { id 'fabric-loom' version '0.2.0-SNAPSHOT' + id 'maven-publish' } sourceCompatibility = JavaVersion.VERSION_1_8 @@ -35,3 +36,49 @@ task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' from sourceSets.main.allSource } + +// create a javadoc file for publishing +task javadocJar(type: Jar, dependsOn: javadoc) { + from javadoc.destinationDir + from "LICENSE" + classifier = "javadoc" +} + +// make the javadoc tool be more lenient when using Java 8 +// this fixes the javadoc tool breaking on things like self-closed
tags +// see https://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html +if (JavaVersion.current().isJava8Compatible()) { + allprojects { + tasks.withType(Javadoc) { + options.addStringOption('Xdoclint:none', '-quiet') + } + } +} + +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 + artifact javadocJar + artifact sourcesJar + } + } + + // select the repositories you want to publish to + repositories { + // uncomment to publish to the local maven + // mavenLocal() + } +} + +// make sure that jars are properly remapped before uploading +tasks.publish.dependsOn build +tasks.build.dependsOn javadocJar + From c11457535461a818ab5e3f7d967fbaee28d046b8 Mon Sep 17 00:00:00 2001 From: UpcraftLP Date: Fri, 15 Feb 2019 22:16:07 +0100 Subject: [PATCH 5/9] update fabric URL --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 6a5fbb2..0c227e6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties - # check these on https://fabric.asie.pl/use + # check these on https://fabricmc.net/use minecraft_version=19w07a yarn_mappings=19w07a.6 loader_version=0.3.6.107 From 9101ee4ee98aa1a26acfc1181ccd681ff6e5c6ea Mon Sep 17 00:00:00 2001 From: UpcraftLP Date: Fri, 15 Feb 2019 22:25:50 +0100 Subject: [PATCH 6/9] fix maven publishing --- build.gradle | 1 + gradle.properties | 1 + 2 files changed, 2 insertions(+) diff --git a/build.gradle b/build.gradle index 377c613..1ef975e 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,7 @@ targetCompatibility = JavaVersion.VERSION_1_8 archivesBaseName = project.archives_base_name version = project.mod_version +group = project.maven_group minecraft { } diff --git a/gradle.properties b/gradle.properties index 0c227e6..bba5f93 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,7 @@ org.gradle.jvmargs=-Xmx1G # Mod Properties mod_version = 1.0.0 + maven_group = net.fabricmc archives_base_name = fabric-example-mod # Dependencies From 8c0584bbaf15d3c63ba38e35dfc90eae2cd73ecc Mon Sep 17 00:00:00 2001 From: UpcraftLP Date: Fri, 15 Feb 2019 22:26:03 +0100 Subject: [PATCH 7/9] fix indentation --- build.gradle | 58 +++++++++++++++++++++++------------------------ gradle.properties | 18 +++++++-------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/build.gradle b/build.gradle index 1ef975e..4815d67 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'fabric-loom' version '0.2.0-SNAPSHOT' - id 'maven-publish' + id 'maven-publish' } sourceCompatibility = JavaVersion.VERSION_1_8 @@ -14,7 +14,7 @@ minecraft { } dependencies { - //to change the versions see the gradle.properties file + //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}" @@ -27,7 +27,7 @@ dependencies { // 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" + options.encoding = "UTF-8" } // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task @@ -40,46 +40,46 @@ task sourcesJar(type: Jar, dependsOn: classes) { // create a javadoc file for publishing task javadocJar(type: Jar, dependsOn: javadoc) { - from javadoc.destinationDir - from "LICENSE" - classifier = "javadoc" + from javadoc.destinationDir + from "LICENSE" + classifier = "javadoc" } // make the javadoc tool be more lenient when using Java 8 // this fixes the javadoc tool breaking on things like self-closed
tags // see https://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html if (JavaVersion.current().isJava8Compatible()) { - allprojects { - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - } - } + allprojects { + tasks.withType(Javadoc) { + options.addStringOption('Xdoclint:none', '-quiet') + } + } } jar { - from "LICENSE" + from "LICENSE" } // configure the maven publication publishing { - publications { + publications { + mavenJava(MavenPublication) { + // add all the jars that should be included when publishing to maven + artifact(jar) { + builtBy remapJar + } + artifact javadocJar + artifact(sourcesJar) { + builtBy remapSourcesJar + } + } + } - mavenJava(MavenPublication) { - // add all the jars that should be included when publishing to maven - artifact jar - artifact javadocJar - artifact sourcesJar - } - } - - // select the repositories you want to publish to - repositories { - // uncomment to publish to the local maven - // mavenLocal() - } + // select the repositories you want to publish to + repositories { + // uncomment to publish to the local maven + // mavenLocal() + } } - -// make sure that jars are properly remapped before uploading -tasks.publish.dependsOn build tasks.build.dependsOn javadocJar diff --git a/gradle.properties b/gradle.properties index bba5f93..5e987a0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,16 +2,16 @@ 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 + # 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 + 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 + # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric + fabric_version=0.2.1.94 From 8243775b5cfc2108245d8cfb5a7dd1cc2c661e69 Mon Sep 17 00:00:00 2001 From: UpcraftLP Date: Fri, 15 Feb 2019 22:39:48 +0100 Subject: [PATCH 8/9] automatically set mod version on export --- build.gradle | 22 ++++++++++++++++++++-- src/main/resources/fabric.mod.json | 2 +- 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" From e7fad09f14f117879f94d9b3b18e53b921572c8f Mon Sep 17 00:00:00 2001 From: UpcraftLP Date: Fri, 15 Feb 2019 22:41:11 +0100 Subject: [PATCH 9/9] remove javadoc jar --- build.gradle | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/build.gradle b/build.gradle index e29d985..0c38eca 100644 --- a/build.gradle +++ b/build.gradle @@ -56,24 +56,6 @@ task sourcesJar(type: Jar, dependsOn: classes) { from sourceSets.main.allSource } -// create a javadoc file for publishing -task javadocJar(type: Jar, dependsOn: javadoc) { - from javadoc.destinationDir - from "LICENSE" - classifier = "javadoc" -} - -// make the javadoc tool be more lenient when using Java 8 -// this fixes the javadoc tool breaking on things like self-closed
tags -// see https://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html -if (JavaVersion.current().isJava8Compatible()) { - allprojects { - tasks.withType(Javadoc) { - options.addStringOption("Xdoclint:none", "-quiet") - } - } -} - jar { from "LICENSE" } @@ -86,7 +68,6 @@ publishing { artifact(jar) { builtBy remapJar } - artifact javadocJar artifact(sourcesJar) { builtBy remapSourcesJar } @@ -99,5 +80,3 @@ publishing { // mavenLocal() } } -tasks.build.dependsOn javadocJar -