-
Notifications
You must be signed in to change notification settings - Fork 18
/
build.gradle
executable file
·72 lines (61 loc) · 1.95 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
import org.teavm.gradle.api.OptimizationLevel
buildscript {
dependencies {
classpath files("src/teavmc-classpath/resources")
}
}
plugins {
id "java"
id "eclipse"
id "org.teavm" version "0.9.2"
}
sourceSets {
main {
java {
srcDirs(
"src/main/java",
"src/game/java",
"src/protocol-game/java",
"src/protocol-relay/java",
"src/teavm/java",
"src/teavm-boot-menu/java"
)
}
}
}
repositories {
mavenCentral()
}
dependencies {
teavm(teavm.libs.jso)
teavm(teavm.libs.jsoApis)
compileOnly "org.teavm:teavm-core:0.9.2" // workaround for a few hacks
}
def folder = "javascript"
def name = "classes.js"
teavm.js {
obfuscated = true
sourceMap = true
targetFileName = "../" + name
optimization = OptimizationLevel.BALANCED // Change to "AGGRESSIVE" for release
outOfProcess = false
fastGlobalAnalysis = false
processMemory = 512
entryPointName = "main"
mainClass = "net.lax1dude.eaglercraft.v1_8.internal.teavm.MainClass"
outputDir = file(folder)
properties = [ "java.util.TimeZone.autodetect": "true" ]
debugInformation = false
}
tasks.named("generateJavaScript") {
doLast {
// NOTE: This step may break at any time, and is not required for 99% of browsers
def phile = file(folder + "/" + name)
def dest = phile.getText("UTF-8")
def i = dest.substring(0, dest.indexOf("=\$rt_globals.Symbol('jsoClass');")).lastIndexOf("let ")
dest = dest.substring(0, i) + "var" + dest.substring(i + 3)
def j = dest.indexOf("function(\$rt_globals,\$rt_exports){")
dest = dest.substring(0, j + 34) + "\n" + file(folder + "/ES6ShimScript.txt").getText("UTF-8") + "\n" + dest.substring(j + 34)
phile.write(dest, "UTF-8")
}
}