split Project into multiple Modules to prepare for development of Servers

This commit is contained in:
Valentin Heiserer
2024-04-18 00:26:11 +02:00
committed by GitHub
parent 949c00bb28
commit c94127acf1
79 changed files with 200 additions and 155 deletions

View File

@@ -34,9 +34,6 @@ jobs:
run: npm run build
working-directory: Frontend
- name: Copy built Frontend
run: rm -r Backend/src/main/resources/web-content/ && mv Frontend/dist Backend/src/main/resources/web-content
- name: Set up JDK 21
uses: actions/setup-java@v4
with:

View File

@@ -4,7 +4,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>schafkopf-backend-java</artifactId>
<groupId>org.example</groupId>
<packaging>pom</packaging>
<modules>
<module>schafkopf-client</module>
<module>schafkopf-server</module>
<module>schafkopf-shared</module>
</modules>
<groupId>org.schafkopf</groupId>
<modelVersion>4.0.0</modelVersion>
<version>1.0-SNAPSHOT</version>
@@ -20,11 +26,6 @@
<build>
<finalName>schafkopf-backend-build</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<!-- Maven Clean Plugin -->
<plugin>
@@ -82,29 +83,6 @@
</plugin>
<!-- Maven Assembly Plugin -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>org.schafkopf.BackendServer</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
@@ -157,15 +135,5 @@
<groupId>io.github.cdimascio</groupId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>22</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>22</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.schafkopf</groupId>
<artifactId>schafkopf-backend-java</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>schafkopf-client</artifactId>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.schafkopf</groupId>
<artifactId>schafkopf-shared</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>schafkopf-client-build</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>org.schafkopf.BackendServer</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -4,26 +4,26 @@ import com.google.gson.JsonObject;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import io.github.cdimascio.dotenv.Dotenv;
import jakarta.servlet.DispatcherType;
import java.awt.Desktop;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.time.Duration;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import javafx.application.Application;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlets.CrossOriginFilter;
import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
import org.schafkopf.cardreader.CardReader;
import org.schafkopf.cardreader.UsbCardReader;
/** Main Class that represents the Backend Server. */
@@ -37,14 +37,12 @@ public class BackendServer {
/** Important variables. */
public final Schafkopf schafkopfGame;
private final CardReader nfcLeser;
private final List<FrontendEndpoint> frontendEndpoints = new ArrayList<>();
/** Creates an Instance of the Backend Server. */
public BackendServer() {
Dotenv dotenv = Dotenv.configure().directory("./").load();
public BackendServer() throws URISyntaxException, IOException {
server = new Server();
InetSocketAddress address = new InetSocketAddress(dotenv.get("VITE_APP_WEBSOCKET_IP"), 8080);
InetSocketAddress address = new InetSocketAddress("localhost", 8080);
connector = new ServerConnector(server);
connector.setHost(address.getHostName());
connector.setPort(address.getPort());
@@ -52,8 +50,7 @@ public class BackendServer {
schafkopfGame = new Schafkopf(this);
nfcLeser = new UsbCardReader(this);
new UsbCardReader(this);
// Setup the basic application "context" for this application at "/"
// This is also known as the handler tree (in jetty speak)
@@ -87,11 +84,8 @@ public class BackendServer {
// Integrate simple HTTP server
startHttpServer();
new Thread(this::launchJavaFx).start();
}
private void launchJavaFx() {
Application.launch(JavaFxApp.class);
URI uri = new URI("http://localhost:8081"); // Replace with your target URL
Desktop.getDesktop().browse(uri);
}
private void startHttpServer() {

View File

Before

Width:  |  Height:  |  Size: 815 KiB

After

Width:  |  Height:  |  Size: 815 KiB

View File

Before

Width:  |  Height:  |  Size: 859 KiB

After

Width:  |  Height:  |  Size: 859 KiB

View File

Before

Width:  |  Height:  |  Size: 971 KiB

After

Width:  |  Height:  |  Size: 971 KiB

View File

Before

Width:  |  Height:  |  Size: 954 KiB

After

Width:  |  Height:  |  Size: 954 KiB

View File

Before

Width:  |  Height:  |  Size: 797 KiB

After

Width:  |  Height:  |  Size: 797 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

View File

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

View File

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

Before

Width:  |  Height:  |  Size: 603 KiB

After

Width:  |  Height:  |  Size: 603 KiB

View File

Before

Width:  |  Height:  |  Size: 646 KiB

After

Width:  |  Height:  |  Size: 646 KiB

View File

Before

Width:  |  Height:  |  Size: 730 KiB

After

Width:  |  Height:  |  Size: 730 KiB

View File

Before

Width:  |  Height:  |  Size: 768 KiB

After

Width:  |  Height:  |  Size: 768 KiB

View File

Before

Width:  |  Height:  |  Size: 905 KiB

After

Width:  |  Height:  |  Size: 905 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

View File

Before

Width:  |  Height:  |  Size: 1008 KiB

After

Width:  |  Height:  |  Size: 1008 KiB

View File

Before

Width:  |  Height:  |  Size: 870 KiB

After

Width:  |  Height:  |  Size: 870 KiB

View File

Before

Width:  |  Height:  |  Size: 412 KiB

After

Width:  |  Height:  |  Size: 412 KiB

View File

Before

Width:  |  Height:  |  Size: 470 KiB

After

Width:  |  Height:  |  Size: 470 KiB

View File

Before

Width:  |  Height:  |  Size: 498 KiB

After

Width:  |  Height:  |  Size: 498 KiB

View File

Before

Width:  |  Height:  |  Size: 626 KiB

After

Width:  |  Height:  |  Size: 626 KiB

View File

Before

Width:  |  Height:  |  Size: 957 KiB

After

Width:  |  Height:  |  Size: 957 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

Before

Width:  |  Height:  |  Size: 1010 KiB

After

Width:  |  Height:  |  Size: 1010 KiB

View File

Before

Width:  |  Height:  |  Size: 959 KiB

After

Width:  |  Height:  |  Size: 959 KiB

View File

Before

Width:  |  Height:  |  Size: 686 KiB

After

Width:  |  Height:  |  Size: 686 KiB

File diff suppressed because one or more lines are too long

View File

Before

Width:  |  Height:  |  Size: 600 KiB

After

Width:  |  Height:  |  Size: 600 KiB

View File

Before

Width:  |  Height:  |  Size: 704 KiB

After

Width:  |  Height:  |  Size: 704 KiB

View File

Before

Width:  |  Height:  |  Size: 741 KiB

After

Width:  |  Height:  |  Size: 741 KiB

View File

Before

Width:  |  Height:  |  Size: 881 KiB

After

Width:  |  Height:  |  Size: 881 KiB

View File

Before

Width:  |  Height:  |  Size: 1009 KiB

After

Width:  |  Height:  |  Size: 1009 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

View File

Before

Width:  |  Height:  |  Size: 1015 KiB

After

Width:  |  Height:  |  Size: 1015 KiB

View File

Before

Width:  |  Height:  |  Size: 958 KiB

After

Width:  |  Height:  |  Size: 958 KiB

View File

@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Vite + Vue + TS</title>
<script type="module" crossorigin src="/assets/index-DZ_vcdmw.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-8PJRhba5.css">
</head>
<body class="bg-zinc-800">
<div id="app"></div>
</body>

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.schafkopf</groupId>
<artifactId>schafkopf-backend-java</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>schafkopf-server</artifactId>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.schafkopf</groupId>
<artifactId>schafkopf-shared</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>schafkopf-server-build</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>org.schafkopf.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,18 @@
package org.schafkopf;
import org.schafkopf.karte.Karte;
import org.schafkopf.karte.KartenListe;
import org.schafkopf.karte.KartenUtil;
/** Creates an Instance of the Backend Server. */
public class Main {
/** Creates an Instance of the Backend Server. */
public static void main(String[] args) {
System.out.println("Hello and welcome!");
KartenListe testHand = KartenUtil.zieheZufallsHand(8);
for (Karte karte : testHand.getKartenListe()) {
System.out.println(karte.getName());
}
}
}

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.schafkopf</groupId>
<artifactId>schafkopf-backend-java</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>schafkopf-shared</artifactId>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@@ -1,50 +0,0 @@
package org.schafkopf;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
/** Frontend Window. */
public class JavaFxApp extends Application {
private static final String FRONTEND_URL =
"http://localhost:8081"; // Replace with your frontend URL
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
// Create a WebView
WebView webView = new WebView();
// Load the frontend URL
webView.getEngine().load(FRONTEND_URL);
// Create a Scene with the WebView
Scene scene = new Scene(webView, 800, 600);
// Set up the Stage
primaryStage.setTitle("Schafkopfen");
primaryStage.setScene(scene);
primaryStage.setFullScreenExitHint("");
// Set the stage to fullscreen
primaryStage.setFullScreen(true);
// Add event handler for the Escape key to toggle fullscreen
scene.setOnKeyPressed(
event -> {
if (event.getCode() == KeyCode.F11) {
primaryStage.setFullScreen(!primaryStage.isFullScreen());
}
});
// Show the Stage
primaryStage.show();
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>

Before

Width:  |  Height:  |  Size: 496 B

View File

@@ -1,15 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue</title>
<script type="module" crossorigin src="/assets/index-6278b98f.js"></script>
<link rel="stylesheet" href="/assets/index-08f560d4.css">
</head>
<body class="bg-gray-800">
<div id="app"></div>
</body>
</html>

View File

@@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"build": "vue-tsc && vite build --emptyOutDir",
"preview": "vite preview"
},
"dependencies": {

View File

@@ -134,20 +134,20 @@ onMounted(() => {
<div class="flex gap-2 place-content-center">
<button @click="setGame('setgame:sauspiel')">Sauspiel</button>
<button @click="setGame('setgame:herzsolo')">herzsolo</button>
<button @click="setGame('setgame:eichelsolo')">eichelsolo</button>
<button @click="setGame('setgame:blattsolo')">blattsolo</button>
<button @click="setGame('setgame:schellsolo')">schellsolo</button>
<!-- <button @click="setGame('setgame:herzsolo')">herzsolo</button>-->
<!-- <button @click="setGame('setgame:eichelsolo')">eichelsolo</button>-->
<!-- <button @click="setGame('setgame:blattsolo')">blattsolo</button>-->
<!-- <button @click="setGame('setgame:schellsolo')">schellsolo</button>-->
<button @click="setGame('setgame:eichelwenz')">eichelwenz</button>
<button @click="setGame('setgame:blattwenz')">blattwenz</button>
<button @click="setGame('setgame:herzwenz')">herzwenz</button>
<button @click="setGame('setgame:schellwenz')">schellwenz</button>
<!-- <button @click="setGame('setgame:eichelwenz')">eichelwenz</button>-->
<!-- <button @click="setGame('setgame:blattwenz')">blattwenz</button>-->
<!-- <button @click="setGame('setgame:herzwenz')">herzwenz</button>-->
<!-- <button @click="setGame('setgame:schellwenz')">schellwenz</button>-->
<button @click="setGame('setgame:eichelgeier')">eichelgeier</button>
<button @click="setGame('setgame:blattgeier')">blattgeier</button>
<button @click="setGame('setgame:herzgeier')">herzgeier</button>
<button @click="setGame('setgame:schellgeier')">schellgeier</button>
<!-- <button @click="setGame('setgame:eichelgeier')">eichelgeier</button>-->
<!-- <button @click="setGame('setgame:blattgeier')">blattgeier</button>-->
<!-- <button @click="setGame('setgame:herzgeier')">herzgeier</button>-->
<!-- <button @click="setGame('setgame:schellgeier')">schellgeier</button>-->
<button @click="setGame('setgame:geier')">Geier</button>
<button @click="setGame('setgame:wenz')">Wenz</button>

View File

@@ -1,7 +1,10 @@
import { defineConfig } from 'vite'
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
plugins: [vue()],
build: {
outDir: '../Backend/src/main/resources/web-content',
},
})