eaglercraft-1.8-workspace/build.gradle

72 lines
1.9 KiB
Groovy
Raw Normal View History

2024-09-21 22:29:10 -07:00
import org.teavm.gradle.api.OptimizationLevel
buildscript {
dependencies {
classpath files("src/teavmc-classpath/resources")
}
}
2024-02-14 20:52:11 -08:00
plugins {
2024-09-21 22:29:10 -07:00
id "java"
id "eclipse"
id "org.teavm" version "0.9.2"
2024-02-14 20:52:11 -08:00
}
sourceSets {
main {
java {
2024-09-21 22:29:10 -07:00
srcDirs(
"src/main/java",
"src/game/java",
"src/protocol-game/java",
"src/protocol-relay/java",
"src/teavm/java",
"src/teavm-boot-menu/java"
)
2024-02-14 20:52:11 -08:00
}
}
2024-09-21 22:29:10 -07:00
2024-02-14 20:52:11 -08:00
}
repositories {
mavenCentral()
}
dependencies {
teavm(teavm.libs.jso)
teavm(teavm.libs.jsoApis)
2024-09-21 22:29:10 -07:00
compileOnly "org.teavm:teavm-core:0.9.2" // workaround for a few hacks
2024-02-14 20:52:11 -08:00
}
2024-09-21 22:29:10 -07:00
def folder = "javascript"
def name = "classes.js"
2024-02-14 20:52:11 -08:00
teavm.js {
obfuscated = true
sourceMap = true
2024-09-21 22:29:10 -07:00
targetFileName = "../" + name
optimization = OptimizationLevel.BALANCED // Change to "AGGRESSIVE" for release
2024-02-14 20:52:11 -08:00
outOfProcess = false
fastGlobalAnalysis = false
processMemory = 512
2024-09-21 22:29:10 -07:00
entryPointName = "main"
mainClass = "net.lax1dude.eaglercraft.v1_8.internal.teavm.MainClass"
outputDir = file(folder)
properties = [ "java.util.TimeZone.autodetect": "true" ]
2024-02-14 20:52:11 -08:00
debugInformation = false
}
2024-09-21 22:29:10 -07:00
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")
}
}