-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
184 lines (161 loc) · 5.96 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
buildscript {
repositories {
maven { url "https://maven.minecraftforge.net" }
maven { url 'https://repo.spongepowered.org/maven'}
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT"
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
}
}
plugins {
id "java"
id "com.github.johnrengelman.shadow" version "2.0.4"
}
apply plugin: "net.minecraftforge.gradle.forge"
apply plugin: 'org.spongepowered.mixin'
//TODO: Change the version, group, and archivesBaseName to your own.
version = "1.0" // The version number of your mod.
group = "com.example" // This is the group of the mod (usually domain or your name -> at.manuthebyte)
archivesBaseName = "examplemod" // This is the name of the jar that is generated.
sourceCompatibility = targetCompatibility = 1.8 // Java version to compile for.
compileJava.options.encoding = "UTF-8" // Make sure that the encoding is set to UTF-8, so we have no encoding issues.
minecraft {
version = "1.8.9-11.15.1.2318-1.8.9" // Version 1.8.9
runDir = "run" // Where to put the forge run data (mods, configs, etc.), in a normal minecraft installation this is .minecraft
mappings = "stable_22" // The mappings for 1.8.9
makeObfSourceJar = false // Disables the creation of a source jar
}
// This is the configuration for the shadow plugin, which is used to add libraries to the jar.
configurations {
shade
compile.extendsFrom(shade)
}
// Configures the SpongePowered Repository
repositories {
maven { url 'https://repo.spongepowered.org/maven/' }
}
def systemOs = System.getProperty("os.name").toLowerCase(Locale.ENGLISH)
/**
* This is where we bundle mixins into the jar.
* shade -> bundles the library into the jar
* compile -> library only available at compile time (not accessible at runtime)
*/
dependencies {
shade('org.spongepowered:mixin:0.7.10-SNAPSHOT') {
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
exclude module: 'commons-io'
exclude module: 'log4j-core'
}
if (systemOs.contains("mac"))
{
compile 'org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209'
compile 'org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209'
compile 'org.lwjgl.lwjgl:lwjgl-platform:2.9.4-nightly-20150209'
}
else if (systemOs.contains("linux"))
{
compile 'org.lwjgl.lwjgl:lwjgl_util:2.9.4-babric.1'
compile 'org.lwjgl.lwjgl:lwjgl:2.9.4-babric.1'
compile 'org.lwjgl.lwjgl:lwjgl-platform:2.9.4-babric.1'
}
}
if (systemOs.contains("mac"))
{
configurations.all
{
resolutionStrategy
{
dependencySubstitution
{
substitute module('org.lwjgl.lwjgl:lwjgl_util:2.9.2-nightly-201408222') with module('org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209')
substitute module('org.lwjgl.lwjgl:lwjgl:2.9.2-nightly-201408222') with module('org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209')
}
force 'org.lwjgl.lwjgl:lwjgl-platform:2.9.4-nightly-20150209'
}
}
} else if (systemOs.contains("linux"))
{
configurations.all
{
resolutionStrategy
{
dependencySubstitution
{
substitute module('org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209') using module('org.lwjgl.lwjgl:lwjgl_util:2.9.4-babric.1')
substitute module('org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209') using module('org.lwjgl.lwjgl:lwjgl:2.9.4-babric.1')
}
force 'org.lwjgl.lwjgl:lwjgl-platform:2.9.4-babric.1'
}
}
}
processResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// Replaces version in mcmod.info with the project version.
from(sourceSets.main.resources.srcDirs) {
include "mcmod.info"
//replace version and mcversion
expand "version":project.version, "mcversion":project.minecraft.version
}
// Copies all other resources.
from(sourceSets.main.resources.srcDirs) {
exclude "mcmod.info"
}
rename '(.+_at.cfg)', 'META-INF/$1'
}
// This is the configuration for the shadow plugin, which is used to add libraries to the jar.
shadowJar {
dependencies {}
configurations = [project.configurations.shade] // Adds the gradle configuration "shade" so we can use it.
duplicatesStrategy DuplicatesStrategy.EXCLUDE // Prevents duplicates
classifier ""
}
reobf {
// Reobfuscates the jar.
shadowJar {}
}
/**
* Adds the manifest values
* FMLCorePlugin -> Put the Mixin Loader here
* ModSide -> Client or Server
* TweakClass -> Mixin tweaker
* MixinConfigs -> Put your mixin config here (mixins.MODID.json)
*/
//TODO: Change the FMLCorePlugin to the mixin loader with your own package
//TODO: Add your own MixinConfig(s)
jar {
manifest.attributes(
"FMLCorePlugin" : "com.example.examplemod.mixins.MixinLoader",
"ForceLoadAsMod": true,
"TweakOrder": 0,
"ModSide": "CLIENT",
'FMLCorePluginContainsFMLMod': true,
'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
'MixinConfigs': 'mixins.examplemod.json'
)
}
// This adds the refmap.
// (You do not need to create the refmap, it is created automatically by the mixin plugin)
//TODO: Change the refmap name to your own
sourceSets {
main {
ext.refMap = "mixins.examplemod.refmap.json"
}
}
// Task that will build the mod and copy it to your instance (need to change the path to your instance)
//TODO: (Optional) Change the path to your instance
task buildAndCopyToMods(type: Copy, dependsOn: 'build') {
from "build/libs"
into "<yourRealInstance>/.minecraft/mods"
include "*.jar"
}
// Task that will build the mod and put it in the "run" folder, and then run the client.
task buildCopyToRunModsAndRun(type: Copy, dependsOn: 'build') {
from "build/libs"
into "run/mods"
include "*.jar"
}
buildCopyToRunModsAndRun.finalizedBy runClient