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