1- buildscript {
2- repositories {
3- jcenter()
4- maven {
5- name = " forge"
6- url = " http://files.minecraftforge.net/maven"
7- }
8- }
9- dependencies {
10- classpath ' net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
11- }
12- }
13- apply plugin : ' net.minecraftforge.gradle.forge'
14- compileJava {
15- sourceCompatibility = ' 8'
16- targetCompatibility = ' 1.8'
1+ plugins {
2+ id " java"
3+ id " com.github.johnrengelman.shadow" version " 6.1.0"
4+ id " net.minecraftforge.gradle.forge" version " 6f53277"
175}
186
7+ sourceCompatibility = targetCompatibility = 1.8
8+ compileJava. options. encoding = ' UTF-8'
9+
1910archivesBaseName = ' RewardClaim'
20- version = ' 0.1.1 '
11+ version = ' 0.2 '
2112group = ' me.dancedog.rewardclaim'
13+
2214minecraft {
23- version = ' 1.8.9-11.15.1.1722'
24- runDir = ' run'
25- mappings = ' stable_20'
15+ version = " 1.8.9-11.15.1.2318-1.8.9"
16+ runDir = " run"
17+ mappings = " stable_22"
18+ makeObfSourceJar = false
2619}
2720
2821configurations {
29- shade
30- shade. transitive = false
31- compile. extendsFrom(shade)
32- }
33- repositories {
34- mavenCentral()
22+ // Creates an extra configuration that implements `implementation` to be used later as the configuration that shades libraries
23+ include
24+ compile. extendsFrom(include)
3525}
26+
3627dependencies {
37- compileOnly ' org.projectlombok:lombok:1.18.12'
38- annotationProcessor ' org.projectlombok:lombok:1.18.12'
39- shade ' org.jsoup:jsoup:1.13.1'
40- }
41- jar {
42- from configurations. shade. collect {
43- it. isDirectory() ? it : zipTree(it)
44- }
28+ // How to normally add a dependency (If you don't want it to be added to the jar)
29+ // implementation "com.example:example:1.0.0"
30+ // If you would like to include it (have the library inside your jar) instead use
31+ // include "com.example:example:1.0.0"
32+ include ' org.jsoup:jsoup:1.14.1'
4533}
4634
35+ /**
36+ * This task simply replaces the `${version}` and `${mcversion}` properties in the mcmod.info with the data from Gradle
37+ */
4738processResources {
4839 // this will ensure that this task is redone when the versions change.
4940 inputs. property " version" , project. version
@@ -54,7 +45,7 @@ processResources {
5445 include ' mcmod.info'
5546
5647 // replace version and mcversion
57- expand ' version' :project. version, ' mcversion' :project. minecraft. version
48+ expand ' version' : project. version, ' mcversion' : project. minecraft. version
5849 }
5950
6051 // copy everything else, thats not the mcmod.info
@@ -63,5 +54,24 @@ processResources {
6354 }
6455}
6556
66- // noinspection GrDeprecatedAPIUsage
67- sourceSets. main. output. classesDir = new File (buildDir, " classes/main" )
57+ /**
58+ * This task simply moves resources so they can be accessed at runtime, Forge is quite weird isn't it
59+ */
60+ task moveResources {
61+ doLast {
62+ ant. move file : " ${ buildDir} /resources/main" ,
63+ todir : " ${ buildDir} /classes/java"
64+ }
65+ }
66+
67+ moveResources. dependsOn processResources
68+ classes. dependsOn moveResources
69+
70+ // This adds support to ("embed", "shade", "include") libraries into our JAR
71+ shadowJar {
72+ archiveClassifier. set(' ' )
73+ duplicatesStrategy DuplicatesStrategy . EXCLUDE
74+ configurations = [project. configurations. include]
75+ }
76+
77+ reobfJar. dependsOn tasks. shadowJar
0 commit comments