From d6b25bc76e59e46a0498f201d9b446930b421c37 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Tue, 17 Jan 2023 17:42:32 +0100 Subject: [PATCH] Add jar-building to pom-file. Fix ConsoleInterface --- pom.xml | 38 ++++++++++++++++++- src/main/java/Main.java | 10 +++++ .../dhbwstuttgart/core/ConsoleInterface.java | 12 ++++-- 3 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 src/main/java/Main.java diff --git a/pom.xml b/pom.xml index 78e5bf45..ca4bae64 100644 --- a/pom.xml +++ b/pom.xml @@ -53,7 +53,9 @@ http://maven.apache.org/maven-v4_0_0.xsd"> 3.8.0 --enable-preview - + 19 + 19 + org.antlr @@ -68,7 +70,39 @@ http://maven.apache.org/maven-v4_0_0.xsd"> - + + org.apache.maven.plugins + maven-jar-plugin + + + + de.dhbwstuttgart.core.ConsoleInterface + + + + + + maven-assembly-plugin + + + package + + single + + + + + + + de.dhbwstuttgart.core.ConsoleInterface + + + + jar-with-dependencies + + + + diff --git a/src/main/java/Main.java b/src/main/java/Main.java new file mode 100644 index 00000000..7a571a4f --- /dev/null +++ b/src/main/java/Main.java @@ -0,0 +1,10 @@ +import de.dhbwstuttgart.core.ConsoleInterface; + +import java.io.IOException; + +public class Main { + + public static void main(String[] args) throws IOException, ClassNotFoundException { + ConsoleInterface.main(args); + } +} diff --git a/src/main/java/de/dhbwstuttgart/core/ConsoleInterface.java b/src/main/java/de/dhbwstuttgart/core/ConsoleInterface.java index 14314d83..946d7f10 100644 --- a/src/main/java/de/dhbwstuttgart/core/ConsoleInterface.java +++ b/src/main/java/de/dhbwstuttgart/core/ConsoleInterface.java @@ -2,10 +2,7 @@ package de.dhbwstuttgart.core; import java.io.File; import java.io.IOException; -import java.net.URL; import java.util.*; -import java.util.stream.Collectors; - public class ConsoleInterface { private static final String directory = System.getProperty("user.dir"); @@ -14,6 +11,15 @@ public class ConsoleInterface { List classpath = new ArrayList<>(); String outputPath = null; Iterator it = Arrays.asList(args).iterator(); + if(args.length == 0){ + System.out.println("No input files given. Get help with --help"); + System.exit(1); + }else if(args.length == 1 && args[0].equals("--help")){ + System.out.println("Usage: javatx [OPTION]... [FILE]...\n" + + "\t-cp\tSet Classpath\n" + + "\t-d\tSet destination directory"); + System.exit(1); + } while(it.hasNext()){ String arg = it.next(); if(arg.equals("-d")){