diff --git a/.github/workflows/buildOnRelease.yml b/.github/workflows/buildOnRelease.yml
index 0b577e9..bf03239 100644
--- a/.github/workflows/buildOnRelease.yml
+++ b/.github/workflows/buildOnRelease.yml
@@ -23,10 +23,11 @@ jobs:
- name: Set versioned JAR name
run: |
$tag = "${{ github.ref_name }}"
- echo "JAR_NAME=APPLICATION-$tag.jar" >> $env:GITHUB_ENV
+ echo "JAR_NAME=MillionsG40-$tag.jar" >> $env:GITHUB_ENV
- name: Rename JAR
- run: mv target/*.jar $env:JAR_NAME
+ run: mv target/*-shaded.jar $env:JAR_NAME
+
- uses: softprops/action-gh-release@v1
with:
diff --git a/pom.xml b/pom.xml
index f5081aa..413910e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
edu.ntnu.idi.idatt2003.g40.mappe
mappe
- 1.1-SNAPSHOT
+ 1.0.0
25
@@ -39,6 +39,29 @@
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.5.0
+
+
+ package
+
+ shade
+
+
+ true
+ shaded
+
+
+
+ edu.ntnu.idi.idatt2003.g40.mappe.Launcher
+
+
+
+
+
+
org.apache.maven.plugins
maven-compiler-plugin
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Launcher.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Launcher.java
new file mode 100644
index 0000000..7d78de0
--- /dev/null
+++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Launcher.java
@@ -0,0 +1,7 @@
+package edu.ntnu.idi.idatt2003.g40.mappe;
+
+public class Launcher {
+ static void main(String[] args) {
+ Main.main(args);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java
index b94ca01..691eaa7 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java
@@ -40,6 +40,10 @@
* */
public class Main extends Application {
+ static void main(String[] args) {
+ launch(args);
+ }
+
/**
* {@inheritDoc}
* */
@@ -57,7 +61,7 @@ public void start(final Stage stage) throws Exception {
ViewManager viewManager = new ViewManager(stage, eventManager);
List stocksInFile;
- FileParser parser1 = new FileParser("src/main/resources/dummydata.txt");
+ FileParser parser1 = new FileParser("/dummydata.txt");
FileConverter converter1 = new FileConverter();
stocksInFile = converter1.getStocksFromStrings(parser1.readFile());
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/service/FileParser.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/service/FileParser.java
index 9d0bf27..481d423 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/service/FileParser.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/service/FileParser.java
@@ -1,9 +1,8 @@
package edu.ntnu.idi.idatt2003.g40.mappe.service;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
+import java.io.*;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -120,8 +119,8 @@ public FileParser(final String pathName) {
* */
public List readFile() throws IOException {
- Path path = Paths.get(pathName);
- try (BufferedReader bufferedReader = Files.newBufferedReader(path)) {
+ try (InputStream inputStream = getClass().getResourceAsStream(pathName);
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
List allLines = bufferedReader.readAllLines();
List readableLines =
diff --git a/src/test/java/edu/ntnu/idi/idatt2003/g40/mappe/service/FileParserTest.java b/src/test/java/edu/ntnu/idi/idatt2003/g40/mappe/service/FileParserTest.java
index e751602..7d87b1a 100644
--- a/src/test/java/edu/ntnu/idi/idatt2003/g40/mappe/service/FileParserTest.java
+++ b/src/test/java/edu/ntnu/idi/idatt2003/g40/mappe/service/FileParserTest.java
@@ -13,7 +13,9 @@
class FileParserTest {
- private final String testStockDataPath = "src/main/resources/testStockData.txt";
+ private final String testStockDataPath = "/testStockData.txt";
+
+ private final String absoluteTestStockDataPath = "src/main/resources/testStockData.txt";
FileParser fileParser;
private final String validStockFromFile = "NVID, Nvidida Corporation, 241.591";
@@ -29,7 +31,7 @@ class FileParserTest {
@BeforeEach
void setUp() throws Exception {
fileParser = new FileParser(testStockDataPath);
- Path path = Paths.get(testStockDataPath);
+ Path path = Paths.get(absoluteTestStockDataPath);
allLines = Files.readAllLines(path);
try {
validStocks = fileParser.readFile();