diff --git a/G-Earth/build.gradle.kts b/G-Earth/build.gradle.kts new file mode 100644 index 0000000..6657a53 --- /dev/null +++ b/G-Earth/build.gradle.kts @@ -0,0 +1,124 @@ +import org.gradle.internal.os.OperatingSystem + +plugins { + id("org.beryx.runtime") version "1.12.5" + id("org.openjfx.javafxplugin") version "0.0.11" + `java-library` +} + +description = "G-Earth" + +repositories { + mavenCentral() +} + +dependencies { + implementation(files("libs/G-Wasm-Minimal-1.0.3.jar")) + implementation("at.favre.lib:bytes:1.5.0") + implementation("com.github.tulskiy:jkeymaster:1.3") + implementation("com.github.ganskef:littleproxy-mitm:1.1.0") + implementation("commons-io:commons-io:2.10.0") + implementation("javax.websocket:javax.websocket-api:1.1") + implementation("org.apache.maven:maven-artifact:3.6.3") + implementation("org.eclipse.jetty:jetty-server:9.4.41.v20210516") + implementation("org.eclipse.jetty.websocket:javax-websocket-server-impl:9.4.41.v20210516") { + exclude("javax.websocket", "javax.websocket-client-api") + } + implementation("org.eclipse.jetty:jetty-http:9.4.41.v20210516") + implementation("org.fxmisc.richtext:richtextfx:0.10.5") + implementation("org.json:json:20190722") + implementation("org.jsoup:jsoup:1.14.2") + implementation("org.slf4j:slf4j-jdk14:2.0.0-alpha0") +} + +java { + sourceCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_17 +} + +javafx { + version = "17.0.2" + modules( + "javafx.base", + "javafx.controls", + "javafx.fxml", + "javafx.graphics", + "javafx.media", + "javafx.swing", + "javafx.web" + ) +} + +application { + mainClass.set("gearth.GEarthLauncher") + applicationName = "G-Earth" +} + +runtime { + addModules( + "java.datatransfer", "java.desktop", "java.prefs", + "java.logging", "java.naming", "java.net.http", + "java.sql", "java.scripting", "java.xml", + "jdk.crypto.ec", "jdk.jfr", "jdk.jsobject", + "jdk.unsupported", "jdk.unsupported.desktop", "jdk.xml.dom" + ) + launcher { + noConsole = true + } + jpackage { + + val currentOs = OperatingSystem.current() + + val imgType = when { + currentOs.isWindows -> "ico" + currentOs.isMacOsX -> "icns" + else -> "png" + } + + // TODO: add support for dark-theme icon, maybe depending on OS theme. + imageOptions.addAll(arrayOf("--icon", "src/main/resources/gearth/ui/themes/G-Earth/logo.$imgType")) + + if (currentOs.isWindows) { + installerOptions.addAll( + listOf( + "--win-per-user-install", + "--win-dir-chooser", + "--win-menu" + ) + ) + } + } +} + +tasks.jpackageImage { + doLast { + val os = OperatingSystem.current() + val outPath = when { + os.isWindows -> project.name + os.isMacOsX -> "${project.name}.app/Contents" + else -> "${project.name}/lib" + } + copy { + val buildResourcesPath = "src/main/resources/build" + when { + os.isWindows -> { + /* + TODO: differentiate between 32bit and 64bit windows. + */ + from("$buildResourcesPath/windows/64bit") + include("G-Mem.exe") + } + os.isMacOsX -> { + from("$buildResourcesPath/mac") + /* + * The`g_mem_mac` executable is generated by a modified version of the G-Mem program. + * + * Which can be found here: https://github.com/dorving/g_mem_mac + */ + include("g_mem_mac") + } + } + into("$buildDir/jpackage/$outPath/app") + } + } +} diff --git a/G-Earth/libs/G-Wasm-Minimal-1.0.3.jar b/G-Earth/libs/G-Wasm-Minimal-1.0.3.jar new file mode 100644 index 0000000..a04e78b Binary files /dev/null and b/G-Earth/libs/G-Wasm-Minimal-1.0.3.jar differ diff --git a/G-Earth/src/main/java/gearth/GEarth.java b/G-Earth/src/main/java/gearth/GEarth.java index c6f7269..8691ab8 100644 --- a/G-Earth/src/main/java/gearth/GEarth.java +++ b/G-Earth/src/main/java/gearth/GEarth.java @@ -3,10 +3,8 @@ package gearth; import gearth.misc.AdminValidator; import gearth.misc.Cacher; import gearth.misc.UpdateChecker; -import gearth.misc.listenerpattern.Observable; import gearth.misc.listenerpattern.ObservableObject; import gearth.ui.GEarthController; -import gearth.ui.subforms.logger.loggerdisplays.PacketLogger; import gearth.ui.themes.Theme; import gearth.ui.themes.ThemeFactory; import gearth.ui.titlebar.TitleBarConfig; @@ -19,9 +17,6 @@ import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.stage.Stage; import javafx.stage.StageStyle; -import sun.misc.Cache; - -import java.util.function.Consumer; public class GEarth extends Application { diff --git a/G-Earth/src/main/java/gearth/GEarthLauncher.java b/G-Earth/src/main/java/gearth/GEarthLauncher.java new file mode 100644 index 0000000..535a82d --- /dev/null +++ b/G-Earth/src/main/java/gearth/GEarthLauncher.java @@ -0,0 +1,11 @@ +package gearth; + +/** + * https://stackoverflow.com/questions/52578072/gradle-openjfx11-error-javafx-runtime-components-are-missing"> + */ +public final class GEarthLauncher { + + public static void main(String[] args) { + GEarth.main(args); + } +} diff --git a/G-Earth/src/main/java/gearth/protocol/connection/proxy/unity/PortRequester.java b/G-Earth/src/main/java/gearth/protocol/connection/proxy/unity/PortRequester.java index 18aac14..21c53fd 100644 --- a/G-Earth/src/main/java/gearth/protocol/connection/proxy/unity/PortRequester.java +++ b/G-Earth/src/main/java/gearth/protocol/connection/proxy/unity/PortRequester.java @@ -1,8 +1,5 @@ package gearth.protocol.connection.proxy.unity; -import javafx.beans.InvalidationListener; -import org.eclipse.jetty.websocket.jsr356.annotations.JsrParamIdText; - import javax.websocket.OnOpen; import javax.websocket.Session; import javax.websocket.server.ServerEndpoint; diff --git a/G-Earth/src/main/resources/build/mac/g_mem_mac b/G-Earth/src/main/resources/build/mac/g_mem_mac new file mode 100755 index 0000000..5278fb2 Binary files /dev/null and b/G-Earth/src/main/resources/build/mac/g_mem_mac differ diff --git a/G-Earth/src/main/resources/gearth/ui/themes/G-Earth/logo.icns b/G-Earth/src/main/resources/gearth/ui/themes/G-Earth/logo.icns new file mode 100644 index 0000000..82d352f Binary files /dev/null and b/G-Earth/src/main/resources/gearth/ui/themes/G-Earth/logo.icns differ diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..e22c723 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,8 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * This project uses @Incubating APIs which are subject to change. + */ + +rootProject.name = "G-Earth-Parent" +include(":G-Earth")