-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle
345 lines (262 loc) · 10.1 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net/' }
mavenCentral()
jcenter()
gradlePluginPortal()
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.73'
classpath "org.apache.maven.plugins:maven-resources-plugin:3.2.0"
classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2'
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'com.github.johnrengelman.shadow'
var dev = "dev"
if (project.hasProperty("dev")) {
version += "-" + dev
}
group = "mchorse.mappet"
archivesBaseName = "mappet"
sourceCompatibility = targetCompatibility = "1.8"
compileJava.options.encoding = 'UTF-8'
minecraft {
mappings channel: 'snapshot', version: '20171003-1.12'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
accessTransformer = file('src/main/resources/META-INF/mappet_at.cfg')
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
workingDirectory project.file('run')
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
jvmArgs("-Xmx1G")
}
server {
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
jvmArgs("-Xmx1G")
}
}
}
dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2860'
compileOnly files("run/libs/blockbuster-${blockbuster}-${mcversion}-dev.jar")
compileOnly files("run/libs/metamorph-${metamorph}-${mcversion}-dev.jar")
compileOnly files("run/libs/mclib-${mclib}-${mcversion}-dev.jar")
compileOnly files("run/libs/aperture-${aperture}-${mcversion}-dev.jar")
implementation("org.reflections:reflections:0.10.2")
implementation("net.minecraftforge:mergetool:0.2.3.3") { force = true }
// You may put jars on which you depend on in ./libs or you may define them like so..
// compile "some.group:artifact:version:classifier"
// compile "some.group:artifact:version"
// Real examples
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// These dependencies get remapped to your current MCP mappings
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}
// Example for how to get properties into the manifest for reading by the runtime...
jar {
}
// Example configuration to allow publishing using the maven-publish task
// This is the preferred method to reobfuscate your jar file
jar.finalizedBy('shadowJar')
jar.finalizedBy('reobfJar')
// 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
//publish.dependsOn('reobfJar')
// BY DYAMO BOLSHOY UMNI MALCHEG
import org.apache.tools.ant.filters.ReplaceTokens
task processSource(type: Sync) {
outputs.upToDateWhen { false }
from sourceSets.main.java
filter(ReplaceTokens, tokens: [
MAPPET : version,
MCLIB : mclib,
METAMORPH : metamorph,
BLOCKBUSTER: blockbuster,
APERTURE : aperture,
])
into "$buildDir/src"
}
compileJava {
source = processSource.outputs
}
shadowJar {
dependencies {
include(dependency("org.reflections:reflections:0.10.2"))
include(dependency("org.slf4j:slf4j-api:1.7.32"))
include(dependency("org.javassist:javassist:3.28.0-GA"))
}
archiveClassifier.set("")
var dependenciesToRelocate = [
"org.reflections",
"org.slf4j",
"javassist"
]
for (dependency in dependenciesToRelocate) {
relocate dependency, "mchorse.mappet.libs." + dependency
}
}
task prepareAssets(type: Copy) {
group = 'build'
inputs.property 'version', project.version
inputs.property "mcversion", mcversion
project.version += "-" + mcversion
from (sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// Replace version
expand(project.properties)
}
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
into project.file('build/classes/java/main')
}
classes.dependsOn(prepareAssets)
tasks.withType(Jar).all { duplicatesStrategy = DuplicatesStrategy.EXCLUDE }
/* Dev build */
task deobfJar(type: Jar) {
from sourceSets.main.output
classifier = 'dev'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
classifier = 'sources'
}
artifacts {
archives deobfJar
archives sourcesJar
}
task scriptingJavadocs(type: Javadoc) {
source = sourceSets.main.allJava
include "mchorse/mappet/api/ui/components/**"
include "mchorse/mappet/client/gui/utils/graphics/Graphic**"
include "mchorse/mappet/api/scripts/user/**"
}
task scriptingJavadocsJson(type: Exec) {
// Writing gradle tasks is PAIN, if you'll ever would need to run this, clone and build:
// https://github.com/mchorse/jsonDoclet
//
// Rename it to jsonDoclet.jar, and place it in the run/ folder
executable "javadoc"
args "-doclet", "mchorse.utils.doclets.JsonDoclet", "-docletpath", "./run/jsonDoclet.jar", "-sourcepath", "./src/main/java/", "-subpackages", "mchorse.mappet.api.scripts.user:mchorse.mappet.api.ui.components:mchorse.mappet.client.gui.utils.graphics"
doLast {
file("src/main/resources/assets/mappet/docs.json").setText(file("docs.json").text)
}
}
tasks.processResources.dependsOn(scriptingJavadocsJson)
/* Comparing keys */
task compareLangFiles {
doLast {
def help = file("src/main/resources/assets/${project.archivesBaseName}/lang/")
def parse = { File file ->
def map = new HashMap()
def splits = file.text.split("\n");
for (split in splits) {
def index = split.indexOf("=")
if (index == -1) {
continue
}
map.put(split.substring(0, index), true)
}
return map
}
if (!help.exists()) {
return
}
def en = file("${help.getAbsolutePath()}/en_US.lang")
def en_map = parse(en)
for (lang_file in help.listFiles()) {
if (!lang_file.name.endsWith(".lang") || lang_file.name.startsWith("en_US")) {
continue
}
def lang_map = parse(lang_file)
def missing = new ArrayList()
def extra = new ArrayList()
for (key in en_map.keySet()) {
if (!lang_map.containsKey(key)) {
missing.add(key)
}
}
for (key in lang_map.keySet()) {
if (!en_map.containsKey(key)) {
extra.add(key)
}
}
missing.sort()
extra.sort()
print("\n")
if (!missing.isEmpty() || !extra.isEmpty()) {
if (!missing.isEmpty()) {
print("Language file ${lang_file.getName()} misses following keys:\n")
for (key in missing) {
print("- ${key}\n")
}
}
if (!extra.isEmpty()) {
print("Language file ${lang_file.getName()} has additional keys:\n")
for (key in extra) {
print("- ${key}\n")
}
}
} else {
print("Language file ${lang_file.getName()} fully matches ${en.getName()}!\n")
}
}
}
}
task copyLangStrings {
doLast {
def parse = { File file ->
def map = new HashMap()
def splits = file.text.split("\n");
for (split in splits) {
def index = split.indexOf("=")
if (index == -1) {
continue
}
map.put(split.substring(0, index), split.substring(index + 1))
}
return map
}
def help = file("src/main/resources/assets/${project.archivesBaseName}/lang/")
def en = file("${help.getAbsolutePath()}/en_US.lang")
for (file in help.listFiles()) {
if (file.name.endsWith(".lang") && !file.name.startsWith("en_")) {
def strings = parse(file)
def splits = en.text.split("\n")
for (def i = 0; i < splits.length; i++) {
def str = splits[i];
if (str.contains("=")) {
def index = str.indexOf("=")
def key = str.substring(0, index)
def value = str.substring(index)
if (strings.containsKey(key)) {
splits[i] = key + "=" + strings.get(key)
}
}
}
file.write(splits.join("\n"))
print("Wrote to ${file.name}...")
}
}
print("Done!")
}
}
tasks.register('openBuiltJarsDir', Exec) {
group = 'build'
description = 'Opens the build/libs directory in Explorer'
commandLine "cmd", "/c", "explorer ${projectDir}\\build\\libs"
ignoreExitValue true
}