Skip to content

Commit

Permalink
Create new jar file
Browse files Browse the repository at this point in the history
  • Loading branch information
ooimingsheng committed Sep 28, 2019
1 parent eb46137 commit 0b4da65
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 46 deletions.
86 changes: 64 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,43 +1,85 @@

plugins {
id 'java'
id 'application'
id 'checkstyle'
id 'com.github.johnrengelman.shadow' version '5.1.0'
id 'org.openjfx.javafxplugin' version '0.0.7'
}

checkstyle {
toolVersion = '8.23'
}

shadowJar {
archiveBaseName = "duke"
archiveVersion = "0.1.3"
archiveClassifier = null
archiveAppendix = null
group 'seedu.duke'
version '0.1.3'
sourceCompatibility = 1.11


def currentOS = org.gradle.internal.os.OperatingSystem.current()
def platform
if (currentOS.isWindows()) {
platform = 'win'
} else if (currentOS.isLinux()) {
platform = 'linux'
} else if (currentOS.isMacOsX()) {
platform = 'mac'
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.0'
compile "org.openjfx:javafx-base:11:win"
compile "org.openjfx:javafx-graphics:11:win"
compile "org.openjfx:javafx-controls:11:win"
compile "org.openjfx:javafx-fxml:11:win"

compile "org.openjfx:javafx-base:11:linux"
compile "org.openjfx:javafx-graphics:11:linux"
compile "org.openjfx:javafx-controls:11:linux"
compile "org.openjfx:javafx-fxml:11:linux"

compile "org.openjfx:javafx-base:11:mac"
compile "org.openjfx:javafx-graphics:11:mac"
compile "org.openjfx:javafx-controls:11:mac"
compile "org.openjfx:javafx-fxml:11:mac"
}

test {
useJUnitPlatform()
application {
// Change this to your main class.
mainClassName = "seedu.duke.DukeFX"
}

group 'seedu.duke'
version '0.1.0'
jar {
manifest {
attributes 'Main-Class': 'seedu.duke.DukeFX'
}
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}

repositories {
mavenCentral()
compileJava {
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'javafx.controls,javafx.fxml'
]
}
}

javafx {
version = "11.0.2"
modules = [ 'javafx.controls', 'javafx.fxml' ]
run {
doFirst {
jvmArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'javafx.controls,javafx.fxml'
]
}
}

application {
// Change this to your main class.
mainClassName = "seedu.duke.Duke"
checkstyle {
toolVersion = '8.23'
}

test {
useJUnitPlatform()
}


repositories {
mavenCentral()
}
Binary file modified docs/Ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 2 additions & 11 deletions src/main/java/seedu/duke/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Duke {
private Storage storage;
private TaskList tasks;
private Ui ui;
private static final String filePath = ".\\data\\duke.txt";
private static final String filePath = "data/duke.txt";
private boolean isSystemRunning;

/**
Expand Down Expand Up @@ -71,21 +71,12 @@ public String getResponse(String message) {
c.execute(tasks, ui, storage);
isSystemRunning = !c.isExit();
return c.getResultOfCommand();
} catch (DukeException e) {
} catch (Exception e) {
return ui.getError(e.getMessage());
}
} else {
return "System has already shut down.";
}
}

/**
* The main class to initialize and drive the program.
*
* @param args parameters recieved from the command line
*/
public static void main(String[] args) {
new Duke().run();
}
}

9 changes: 9 additions & 0 deletions src/main/java/seedu/duke/DukeFX.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package seedu.duke;

public class DukeFX {

public static void main(String[] args) {
Main.main(args);
}

}
23 changes: 12 additions & 11 deletions src/main/java/seedu/duke/task/Storage.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
package seedu.duke.task;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;

public class Storage {

private String filePath;
private File file;
public static String DIVIDER = " XXXDIVIDERXXX ";

/**
* Public constructor that returns a task storage system.
* @param filePath the file path to save and load task data of the system.
*/
public Storage(String filePath) {
this.filePath = filePath;
this.file = new File(filePath);
}

/**
Expand All @@ -27,15 +28,16 @@ public Storage(String filePath) {
public List<Task> load() throws DukeException {
List<Task> taskList = new ArrayList<>();
try {
BufferedReader br = new BufferedReader(new FileReader(filePath));
String line;
while ((line = br.readLine()) != null) {
Scanner sc = new Scanner(file);
while (sc.hasNext()) {
String line = sc.nextLine();
String[] taskParams = line.split(Storage.DIVIDER);
Task task = Task.taskFactory(taskParams);
taskList.add(task);
}
} catch (IOException ioException) {
throw new DukeException("File to be loaded could not be found.");
} catch (FileNotFoundException e) {
file.getParentFile().mkdirs();
return new ArrayList<>();
}
return taskList;
}
Expand All @@ -46,7 +48,7 @@ public List<Task> load() throws DukeException {
* @param ui the user interface to show the saving error if there is an error when saving.
*/
public void saveTasks(List<Task> taskList, Ui ui) {
try (FileWriter writer = new FileWriter(filePath)) {
try (FileWriter writer = new FileWriter(file);) {
for (Task task : taskList) {
if (task instanceof ToDo) {
writer.write("T");
Expand All @@ -67,5 +69,4 @@ public void saveTasks(List<Task> taskList, Ui ui) {
ui.showSavingError();
}
}

}
3 changes: 1 addition & 2 deletions src/main/resources/view/DialogBox.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.HBox?>


<fx:root maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" type="HBox" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<fx:root maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="170.0" prefWidth="500.0" type="HBox" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label fx:id="dialog" />
<ImageView fx:id="displayPicture" fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
Expand Down

0 comments on commit 0b4da65

Please sign in to comment.