1+ import org.apache.tools.ant.filters.ReplaceTokens
2+
13buildscript {
24 repositories {
5+ maven { url = ' https://files.minecraftforge.net/maven' }
36 jcenter()
4- maven { url = " http://files.minecraftforge.net/maven " }
7+ mavenCentral()
58 }
69 dependencies {
7- classpath ' net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT '
10+ classpath ' net.minecraftforge.gradle:ForgeGradle:3.+ '
811 }
912}
10- apply plugin : ' net.minecraftforge.gradle.forge'
11- // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
13+
14+
15+ apply plugin : ' net.minecraftforge.gradle'
16+ // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
17+ apply plugin : ' eclipse'
18+ apply plugin : ' maven-publish'
1219
1320file " build.properties" withReader {
1421 def prop = new Properties ()
@@ -23,67 +30,117 @@ archivesBaseName = "SmartMoving"
2330ext. simpleVersion = version
2431version = " ${ config.minecraft.version} -${ project.version} "
2532
26- sourceCompatibility = targetCompatibility = ' 1.8' // Need this here so eclipse task generates correctly.
27- compileJava {
28- sourceCompatibility = targetCompatibility = ' 1.8'
33+ sourceCompatibility = targetCompatibility = compileJava. sourceCompatibility = compileJava. targetCompatibility = ' 1.8' // Need this here so eclipse task generates correctly.
34+
35+ task updateVersion (type : Copy ) {
36+ from(' src' )
37+ {
38+ exclude ' mcmod.info'
39+ }
40+ into ' build/sources/java'
41+ filter(ReplaceTokens , tokens : [VERSION : project. version. toString()])
2942}
3043
31- compileJava. options. encoding = ' UTF-8'
44+ compileJava. dependsOn updateVersion
45+ compileJava. source = ' build/sources/java'
3246
33- tasks. withType(JavaCompile ) {
34- options. encoding = ' UTF-8'
35- }
47+ minecraft {
48+ mappings channel : ' snapshot' , version : ' 20171003-1.12'
49+
50+ runs {
51+ client {
52+ workingDirectory project. file(' run' )
53+
54+ // Recommended logging data for a userdev environment
55+ property ' forge.logging.markers' , ' SCAN,REGISTRIES,REGISTRYDUMP'
56+
57+ // Recommended logging level for the console
58+ property ' forge.logging.console.level' , ' debug'
3659
37- configurations {
38- provided
39- embedded
40- compile. extendsFrom provided, embedded
60+ // Force-load Player API in dev workspace
61+ property ' fml.coreMods.load' , ' api.player.forge.RenderPlayerAPIPlugin,api.player.forge.PlayerAPIPlugin'
62+ }
63+
64+ server {
65+
66+ // Recommended logging data for a userdev environment
67+ property ' forge.logging.markers' , ' SCAN,REGISTRIES,REGISTRYDUMP'
68+
69+ // Recommended logging level for the console
70+ property ' forge.logging.console.level' , ' debug'
71+
72+ // Force-load Player API in dev workspace
73+ property ' fml.coreMods.load' , ' api.player.forge.RenderPlayerAPIPlugin,api.player.forge.PlayerAPIPlugin'
74+ }
75+ }
4176}
4277
4378dependencies {
44- provided files(" libs/RenderPlayerAPI-1.12.2-1.0.jar" )
79+ // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
80+ // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
81+ // The userdev artifact is a special name and will get all sorts of transformations applied to it.
82+ minecraft ' net.minecraftforge:forge:1.12.2-14.23.5.2854'
83+
84+ implementation files(' libs/RenderPlayerAPI-1.12.2-1.0.jar' )
4585 compile project(" :PlayerAPI" )
4686 compile project(" :SmartRender" )
47- }
4887
49- minecraft {
50- version = " ${ config.minecraft.version} -${ config.forge.version} "
51- runDir = " run"
52-
53- // the mappings can be changed at any time, and must be in the following format.
54- // snapshot_YYYYMMDD snapshot are built nightly.
55- // stable_# stables are built at the discretion of the MCP team.
56- // Use non-default mappings at your own risk. they may not always work.
57- // simply re-run your setup task after changing the mappings to update your workspace.
58- mappings = " ${ config.minecraft.mappings} "
59- // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
60-
61- replace " @VERSION@" , project. simpleVersion
88+ // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
89+ // http://www.gradle.org/docs/current/userguide/dependency_management.html
90+
6291}
6392
93+ // Example for how to get properties into the manifest for reading by the runtime..
6494jar {
65- configurations. embedded. each { dep ->
66- from(project. zipTree(dep)) {
67- exclude ' META-INF' , ' META-INF/**'
68- }
95+ manifest {
96+ attributes([
97+ " Specification-Title" : " smartmoving" ,
98+ " Specification-Vendor" : " doch13_" ,
99+ " Specification-Version" : " 1" , // We are version 1 of ourselves
100+ " Implementation-Title" : project. name,
101+ " Implementation-Version" : " ${ version} " ,
102+ " Implementation-Vendor" :" doch13_" ,
103+ " Implementation-Timestamp" : new Date (). format(" yyyy-MM-dd'T'HH:mm:ssZ" )
104+ ])
69105 }
70106}
71107
72108processResources {
109+ // this will ensure that this task is redone when the versions change.
110+ inputs. property " version" , project. version
111+ inputs. property " mcversion" , " ${ config.minecraft.version} -${ config.forge.version} "
112+
113+ // replace stuff in mcmod.info, nothing else
73114 from(sourceSets. main. resources. srcDirs) {
74115 include ' mcmod.info'
75- expand ' version' : project. simpleVersion, ' mcversion' : config. minecraft. version
116+
117+ // replace version and mcversion
118+ expand ' version' :project. simpleVersion, ' mcversion' :config. minecraft. version
76119 }
77-
120+
121+ // copy everything else except the mcmod.info
78122 from(sourceSets. main. resources. srcDirs) {
79- include ' application.conf'
80- filter { line ->
81- line. replaceAll(" @VERSION@" , project. simpleVersion)
123+ exclude ' mcmod.info'
124+ }
125+ }
126+
127+ // Example configuration to allow publishing using the maven-publish task
128+ // This is the preferred method to reobfuscate your jar file
129+ jar. finalizedBy(' reobfJar' )
130+ // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
131+ // publish.dependsOn('reobfJar')
132+
133+ publishing {
134+ publications {
135+ mavenJava(MavenPublication ) {
136+ artifact jar
82137 }
83138 }
84-
85- from(sourceSets . main . resources . srcDirs) {
86- exclude ' mcmod.info '
87- exclude ' application.conf '
139+ repositories {
140+ maven {
141+ url " file:/// ${ project.projectDir } /mcmodsrepo "
142+ }
88143 }
89144}
145+
146+ sourceSets { main { output. resourcesDir = output. classesDir } }
0 commit comments