diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..6876522 --- /dev/null +++ b/build.gradle @@ -0,0 +1,11 @@ +subprojects { + apply plugin: 'java' + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + javadoc { + options.memberLevel = JavadocMemberLevel.PRIVATE + } + compileJava { + // options.encoding = "UTF-8" + } +} diff --git a/client/build.gradle b/client/build.gradle index bfc0abb..c8761b7 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -21,10 +21,6 @@ javafx { modules = [ 'javafx.controls', 'javafx.graphics' ] } -compileJava { - options.encoding = 'UTF-8' -} - application { // Define the main class for the application. mainClassName = 'fr.lnl.game.client.App' diff --git a/client/src/main/java/fr/lnl/game/client/App.java b/client/src/main/java/fr/lnl/game/client/App.java index 9dd2092..f70b898 100644 --- a/client/src/main/java/fr/lnl/game/client/App.java +++ b/client/src/main/java/fr/lnl/game/client/App.java @@ -24,19 +24,28 @@ public class App extends Application { private static ViewManager viewManager; public static void main(String[] args) { - argsList = new LinkedList<>(Arrays.asList(args)); - argsList.removeIf(s -> s.startsWith("-D") || s.equals("fr.lnl.game.client.App")); // remove given parameters from gradle - Class clazz; - try { - clazz = parseView(); - } catch (IllegalArgumentException e) { - throw new CrashException(e.getMessage(), e); - } - if(clazz.equals(Terminal.class)) { - launchTerminal(); - } else { - launch(); - } + try { + argsList = new LinkedList<>(Arrays.asList(args)); + argsList.removeIf(s -> s.startsWith("-D") || s.equals("fr.lnl.game.client.App")); // remove given parameters from gradle + Class clazz; + try { + clazz = parseView(); + } catch (IllegalArgumentException e) { + throw new CrashException(e.getMessage(), e); + } + if(clazz.equals(Terminal.class)) { + launchTerminal(); + } else { + launch(); + } + } catch(CrashException e) { + System.err.println("Une erreur est survenue et l'application a été obligé de fermer"); + System.err.println(e.getCause().toString()); + for (StackTraceElement element : e.getStackTrace()) { + System.err.println(" at " + element.toString()); + } + System.exit(1); + } } public static void startGame(ViewLambda lambda) throws IllegalArgumentException, InvocationTargetException, NoSuchMethodException, diff --git a/gradle.properties b/gradle.properties index 55cee2b..98a0792 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,2 @@ -org.gradle.jvmargs='-Dfile.encoding=utf-8' \ No newline at end of file +# org.gradle.jvmargs='-Dfile.encoding=UTF-8' +systemProp.file.encoding=UTF-8 \ No newline at end of file diff --git a/server/build.gradle b/server/build.gradle index 31a473a..fcdcfb0 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -8,8 +8,8 @@ plugins { } dependencies { - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' } compileJava { diff --git a/server/src/main/java/fr/lnl/game/server/utils/CrashException.java b/server/src/main/java/fr/lnl/game/server/utils/CrashException.java index 8db0926..a3c9474 100644 --- a/server/src/main/java/fr/lnl/game/server/utils/CrashException.java +++ b/server/src/main/java/fr/lnl/game/server/utils/CrashException.java @@ -4,7 +4,6 @@ public class CrashException extends RuntimeException { public CrashException(String message, Throwable cause) { super(message, cause); - System.exit(1); } diff --git a/server/src/main/java/fr/lnl/game/server/utils/Error.java b/server/src/main/java/fr/lnl/game/server/utils/ErrorMessage.java similarity index 82% rename from server/src/main/java/fr/lnl/game/server/utils/Error.java rename to server/src/main/java/fr/lnl/game/server/utils/ErrorMessage.java index ec7dc6d..e9a4929 100644 --- a/server/src/main/java/fr/lnl/game/server/utils/Error.java +++ b/server/src/main/java/fr/lnl/game/server/utils/ErrorMessage.java @@ -1,6 +1,6 @@ package fr.lnl.game.server.utils; -public class Error { +public class ErrorMessage { public static final String Entry_Error_Message = "\033[0;31mErreur de saisie\033[0m : "; } diff --git a/server/src/main/java/fr/lnl/game/server/utils/Maths.java b/server/src/main/java/fr/lnl/game/server/utils/Maths.java index 059c55f..6bfe792 100644 --- a/server/src/main/java/fr/lnl/game/server/utils/Maths.java +++ b/server/src/main/java/fr/lnl/game/server/utils/Maths.java @@ -6,7 +6,7 @@ public class Maths { public static int testInteger(String entry, Scanner scanner, String error) { while (!isNumeric(entry)) { - System.out.println(Error.Entry_Error_Message + error); + System.out.println(ErrorMessage.Entry_Error_Message + error); entry = scanner.next(); } return Integer.parseInt(entry); @@ -14,7 +14,7 @@ public class Maths { public static float testFloat(String entry, Scanner scanner, String error) { while (!isFloat(entry)) { - System.out.println(Error.Entry_Error_Message + error); + System.out.println(ErrorMessage.Entry_Error_Message + error); entry = scanner.next(); } return Integer.parseInt(entry);