diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000000..fd8c44d086 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,50 @@ +name: Java CI + +on: [push, pull_request] + +jobs: + build: + strategy: + matrix: + platform: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.platform }} + + steps: + - name: Set up repository + uses: actions/checkout@master + + - name: Set up repository + uses: actions/checkout@master + with: + ref: master + + - name: Merge to master + run: git checkout --progress --force ${{ github.sha }} + + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: Setup JDK 11 + uses: actions/setup-java@v1 + with: + java-version: '11' + java-package: jdk+fx + + - name: Build and check with Gradle + run: ./gradlew check + + - name: Perform IO redirection test (*NIX) + if: runner.os == 'Linux' + working-directory: ${{ github.workspace }}/text-ui-test + run: ./runtest.sh + + - name: Perform IO redirection test (MacOS) + if: always() && runner.os == 'macOS' + working-directory: ${{ github.workspace }}/text-ui-test + run: ./runtest.sh + + - name: Perform IO redirection test (Windows) + if: always() && runner.os == 'Windows' + working-directory: ${{ github.workspace }}/text-ui-test + shell: cmd + run: runtest.bat \ No newline at end of file diff --git a/README.md b/README.md index 8715d4d915..f82e2494b7 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,61 @@ This is a project template for a greenfield Java project. It's named after the J ## Setting up in Intellij -Prerequisites: JDK 11, update Intellij to the most recent version. - -1. Open Intellij (if you are not in the welcome screen, click `File` > `Close Project` to close the existing project first) -1. Open the project into Intellij as follows: - 1. Click `Open`. - 1. Select the project directory, and click `OK`. - 1. If there are any further prompts, accept the defaults. -1. Configure the project to use **JDK 11** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).
- In the same dialog, set the **Project language level** field to the `SDK default` option. -3. After that, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output: +Prerequisites: JDK 11 (use the exact version), update Intellij to the most recent version. + +1. **Ensure Intellij JDK 11 is defined as an SDK**, as described [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk) -- this step is not needed if you have used JDK 11 in a previous Intellij project. +1. **Import the project _as a Gradle project_**, as described [here](https://se-education.org/guides/tutorials/intellijImportGradleProject.html). +1. **Verify the set up**: After the importing is complete, locate the `src/main/java/seedu/duke/Duke.java` file, right-click it, and choose `Run Duke.main()`. If the setup is correct, you should see something like the below: ``` + > Task :compileJava + > Task :processResources NO-SOURCE + > Task :classes + + > Task :Duke.main() Hello from ____ _ | _ \ _ _| | _____ | | | | | | | |/ / _ \ | |_| | |_| | < __/ |____/ \__,_|_|\_\___| + + What is your name? ``` + Type some word and press enter to let the execution proceed to the end. + +## Build automation using Gradle + +* This project uses Gradle for build automation and dependency management. It includes a basic build script as well (i.e. the `build.gradle` file). +* If you are new to Gradle, refer to the [Gradle Tutorial at se-education.org/guides](https://se-education.org/guides/tutorials/gradle.html). + +## Testing + +### I/O redirection tests + +* To run _I/O redirection_ tests (aka _Text UI tests_), navigate to the `text-ui-test` and run the `runtest(.bat/.sh)` script. + +### JUnit tests + +* A skeleton JUnit test (`src/test/java/seedu/duke/DukeTest.java`) is provided with this project template. +* If you are new to JUnit, refer to the [JUnit Tutorial at se-education.org/guides](https://se-education.org/guides/tutorials/junit.html). + +## Checkstyle + +* A sample CheckStyle rule configuration is provided in this project. +* If you are new to Checkstyle, refer to the [Checkstyle Tutorial at se-education.org/guides](https://se-education.org/guides/tutorials/checkstyle.html). + +## CI using GitHub Actions + +The project uses [GitHub actions](https://github.com/features/actions) for CI. When you push a commit to this repo or PR against it, GitHub actions will run automatically to build and verify the code as updated by the commit/PR. + +## Documentation + +`/docs` folder contains a skeleton version of the project documentation. + +Steps for publishing documentation to the public: +1. If you are using this project template for an individual project, go your fork on GitHub.
+ If you are using this project template for a team project, go to the team fork on GitHub. +1. Click on the `settings` tab. +1. Scroll down to the `GitHub Pages` section. +1. Set the `source` as `master branch /docs folder`. +1. Optionally, use the `choose a theme` button to choose a theme for your documentation. diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 0000000000..7e1ce222a9 --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,252 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/AboutUs.md b/docs/AboutUs.md new file mode 100644 index 0000000000..0f072953ea --- /dev/null +++ b/docs/AboutUs.md @@ -0,0 +1,9 @@ +# About us + +Display | Name | Github Profile | Portfolio +--------|:----:|:--------------:|:---------: +![](https://via.placeholder.com/100.png?text=Photo) | John Doe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) +![](https://via.placeholder.com/100.png?text=Photo) | Don Joe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) +![](https://via.placeholder.com/100.png?text=Photo) | Ron John | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) +![](https://via.placeholder.com/100.png?text=Photo) | John Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) +![](https://via.placeholder.com/100.png?text=Photo) | Don Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md new file mode 100644 index 0000000000..64e1f0ed2b --- /dev/null +++ b/docs/DeveloperGuide.md @@ -0,0 +1,38 @@ +# Developer Guide + +## Acknowledgements + +{list here sources of all reused/adapted ideas, code, documentation, and third-party libraries -- include links to the original source as well} + +## Design & implementation + +{Describe the design and implementation of the product. Use UML diagrams and short code snippets where applicable.} + + +## Product scope +### Target user profile + +{Describe the target user profile} + +### Value proposition + +{Describe the value proposition: what problem does it solve?} + +## User Stories + +|Version| As a ... | I want to ... | So that I can ...| +|--------|----------|---------------|------------------| +|v1.0|new user|see usage instructions|refer to them when I forget how to use the application| +|v2.0|user|find a to-do item by name|locate a to-do without having to go through the entire list| + +## Non-Functional Requirements + +{Give non-functional requirements} + +## Glossary + +* *glossary item* - Definition + +## Instructions for manual testing + +{Give instructions on how to do a manual product testing e.g., how to load sample data to be used for testing} diff --git a/docs/README.md b/docs/README.md index 8077118ebe..bbcc99c1e7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,29 +1,8 @@ -# User Guide +# Duke -## Features +{Give product intro here} -### Feature-ABC - -Description of the feature. - -### Feature-XYZ - -Description of the feature. - -## Usage - -### `Keyword` - Describe action - -Describe the action and its outcome. - -Example of usage: - -`keyword (optional arguments)` - -Expected outcome: - -Description of the outcome. - -``` -expected output -``` +Useful links: +* [User Guide](UserGuide.md) +* [Developer Guide](DeveloperGuide.md) +* [About Us](AboutUs.md) diff --git a/docs/UserGuide.md b/docs/UserGuide.md new file mode 100644 index 0000000000..abd9fbe891 --- /dev/null +++ b/docs/UserGuide.md @@ -0,0 +1,42 @@ +# User Guide + +## Introduction + +{Give a product intro} + +## Quick Start + +{Give steps to get started quickly} + +1. Ensure that you have Java 11 or above installed. +1. Down the latest version of `Duke` from [here](http://link.to/duke). + +## Features + +{Give detailed description of each feature} + +### Adding a todo: `todo` +Adds a new item to the list of todo items. + +Format: `todo n/TODO_NAME d/DEADLINE` + +* The `DEADLINE` can be in a natural language format. +* The `TODO_NAME` cannot contain punctuation. + +Example of usage: + +`todo n/Write the rest of the User Guide d/next week` + +`todo n/Refactor the User Guide to remove passive voice d/13/04/2020` + +## FAQ + +**Q**: How do I transfer my data to another computer? + +**A**: {your answer here} + +## Command Summary + +{Give a 'cheat sheet' of commands here} + +* Add todo `todo n/TODO_NAME d/DEADLINE` diff --git a/docs/team/johndoe.md b/docs/team/johndoe.md new file mode 100644 index 0000000000..ab75b391b8 --- /dev/null +++ b/docs/team/johndoe.md @@ -0,0 +1,6 @@ +# John Doe - Project Portfolio Page + +## Overview + + +### Summary of Contributions diff --git a/src/main/java/Duke.java b/src/main/java/seedu/duke/Duke.java similarity index 56% rename from src/main/java/Duke.java rename to src/main/java/seedu/duke/Duke.java index 5d313334cc..5c74e68d59 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -1,4 +1,11 @@ +package seedu.duke; + +import java.util.Scanner; + public class Duke { + /** + * Main entry-point for the java.duke.Duke application. + */ public static void main(String[] args) { String logo = " ____ _ \n" + "| _ \\ _ _| | _____ \n" @@ -6,5 +13,9 @@ public static void main(String[] args) { + "| |_| | |_| | < __/\n" + "|____/ \\__,_|_|\\_\\___|\n"; System.out.println("Hello from\n" + logo); + System.out.println("What is your name?"); + + Scanner in = new Scanner(System.in); + System.out.println("Hello " + in.nextLine()); } } diff --git a/src/test/java/seedu/duke/DukeTest.java b/src/test/java/seedu/duke/DukeTest.java new file mode 100644 index 0000000000..2dda5fd651 --- /dev/null +++ b/src/test/java/seedu/duke/DukeTest.java @@ -0,0 +1,12 @@ +package seedu.duke; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +class DukeTest { + @Test + public void sampleTest() { + assertTrue(true); + } +} diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT index 657e74f6e7..892cb6cae7 100644 --- a/text-ui-test/EXPECTED.TXT +++ b/text-ui-test/EXPECTED.TXT @@ -5,3 +5,5 @@ Hello from | |_| | |_| | < __/ |____/ \__,_|_|\_\___| +What is your name? +Hello James Gosling diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt index e69de29bb2..f6ec2e9f95 100644 --- a/text-ui-test/input.txt +++ b/text-ui-test/input.txt @@ -0,0 +1 @@ +James Gosling \ No newline at end of file diff --git a/text-ui-test/runtest.bat b/text-ui-test/runtest.bat index 0873744649..25ac7a2989 100644 --- a/text-ui-test/runtest.bat +++ b/text-ui-test/runtest.bat @@ -1,21 +1,19 @@ -@ECHO OFF +@echo off +setlocal enableextensions +pushd %~dp0 -REM create bin directory if it doesn't exist -if not exist ..\bin mkdir ..\bin +cd .. +call gradlew clean shadowJar -REM delete output from previous run -if exist ACTUAL.TXT del ACTUAL.TXT - -REM compile the code into the bin folder -javac -cp ..\src\main\java -Xlint:none -d ..\bin ..\src\main\java\*.java -IF ERRORLEVEL 1 ( - echo ********** BUILD FAILURE ********** - exit /b 1 +cd build\libs +for /f "tokens=*" %%a in ( + 'dir /b *.jar' +) do ( + set jarloc=%%a ) -REM no error here, errorlevel == 0 -REM run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT -java -classpath ..\bin Duke < input.txt > ACTUAL.TXT +java -jar %jarloc% < ..\..\text-ui-test\input.txt > ..\..\text-ui-test\ACTUAL.TXT + +cd ..\..\text-ui-test -REM compare the output to the expected output -FC ACTUAL.TXT EXPECTED.TXT +FC ACTUAL.TXT EXPECTED.TXT >NUL && ECHO Test passed! || Echo Test failed! diff --git a/text-ui-test/runtest.sh b/text-ui-test/runtest.sh index c9ec870033..1dcbd12021 100755 --- a/text-ui-test/runtest.sh +++ b/text-ui-test/runtest.sh @@ -1,38 +1,23 @@ #!/usr/bin/env bash -# create bin directory if it doesn't exist -if [ ! -d "../bin" ] -then - mkdir ../bin -fi +# change to script directory +cd "${0%/*}" -# delete output from previous run -if [ -e "./ACTUAL.TXT" ] -then - rm ACTUAL.TXT -fi +cd .. +./gradlew clean shadowJar -# compile the code into the bin folder, terminates if error occurred -if ! javac -cp ../src/main/java -Xlint:none -d ../bin ../src/main/java/*.java -then - echo "********** BUILD FAILURE **********" - exit 1 -fi +cd text-ui-test -# run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT -java -classpath ../bin Duke < input.txt > ACTUAL.TXT +java -jar $(find ../build/libs/ -mindepth 1 -print -quit) < input.txt > ACTUAL.TXT -# convert to UNIX format cp EXPECTED.TXT EXPECTED-UNIX.TXT -dos2unix ACTUAL.TXT EXPECTED-UNIX.TXT - -# compare the output to the expected output -diff ACTUAL.TXT EXPECTED-UNIX.TXT +dos2unix EXPECTED-UNIX.TXT ACTUAL.TXT +diff EXPECTED-UNIX.TXT ACTUAL.TXT if [ $? -eq 0 ] then - echo "Test result: PASSED" + echo "Test passed!" exit 0 else - echo "Test result: FAILED" + echo "Test failed!" exit 1 -fi \ No newline at end of file +fi