Skip to content

Commit 861aacc

Browse files
damithcdamithc
authored andcommitted
Provide a minimal project template
Let's add the following features to make this a minimal project template that students can use to start their project. * Gradle support, a basic build script * a skeleton JUnit test * a basic CheckStyle configuration * a basic I/O test setup * support for GitHub actions * documentation skeletons inside the docs folder In addition, let's remove the Gradle and JavaFX tutorials as they are not integral to a project template.
1 parent 8034869 commit 861aacc

File tree

14 files changed

+504
-80
lines changed

14 files changed

+504
-80
lines changed

.github/workflows/gradle.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Java CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
strategy:
8+
matrix:
9+
platform: [ubuntu-latest, macos-latest, windows-latest]
10+
runs-on: ${{ matrix.platform }}
11+
12+
steps:
13+
- name: Set up repository
14+
uses: actions/checkout@master
15+
16+
- name: Set up repository
17+
uses: actions/checkout@master
18+
with:
19+
ref: master
20+
21+
- name: Merge to master
22+
run: git checkout --progress --force ${{ github.sha }}
23+
24+
- name: Validate Gradle Wrapper
25+
uses: gradle/wrapper-validation-action@v1
26+
27+
- name: Setup JDK 17
28+
uses: actions/setup-java@v1
29+
with:
30+
java-version: '17'
31+
java-package: jdk+fx
32+
33+
- name: Build and check with Gradle
34+
run: ./gradlew check
35+
36+
- name: Perform IO redirection test (*NIX)
37+
if: runner.os == 'Linux'
38+
working-directory: ${{ github.workspace }}/text-ui-test
39+
run: ./runtest.sh
40+
41+
- name: Perform IO redirection test (MacOS)
42+
if: always() && runner.os == 'macOS'
43+
working-directory: ${{ github.workspace }}/text-ui-test
44+
run: ./runtest.sh
45+
46+
- name: Perform IO redirection test (Windows)
47+
if: always() && runner.os == 'Windows'
48+
working-directory: ${{ github.workspace }}/text-ui-test
49+
shell: cmd
50+
run: runtest.bat

README.md

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,61 @@ This is a project template for a greenfield Java project. It's named after the J
44

55
## Setting up in Intellij
66

7-
Prerequisites: JDK 17, update Intellij to the most recent version.
8-
9-
1. Open Intellij (if you are not in the welcome screen, click `File` > `Close Project` to close the existing project first)
10-
1. Open the project into Intellij as follows:
11-
1. Click `Open`.
12-
1. Select the project directory, and click `OK`.
13-
1. If there are any further prompts, accept the defaults.
14-
1. Configure the project to use **JDK 17** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).<br>
15-
In the same dialog, set the **Project language level** field to the `SDK default` option.
16-
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:
7+
Prerequisites: JDK 17 (use the exact version), update Intellij to the most recent version.
8+
9+
1. **Ensure Intellij JDK 17 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 17 in a previous Intellij project.
10+
1. **Import the project _as a Gradle project_**, as described [here](https://se-education.org/guides/tutorials/intellijImportGradleProject.html).
11+
1. **Verify the setup**: 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:
1712
```
13+
> Task :compileJava
14+
> Task :processResources NO-SOURCE
15+
> Task :classes
16+
17+
> Task :Duke.main()
1818
Hello from
1919
____ _
2020
| _ \ _ _| | _____
2121
| | | | | | | |/ / _ \
2222
| |_| | |_| | < __/
2323
|____/ \__,_|_|\_\___|
24+
25+
What is your name?
2426
```
27+
Type some word and press enter to let the execution proceed to the end.
28+
29+
## Build automation using Gradle
30+
31+
* This project uses Gradle for build automation and dependency management. It includes a basic build script as well (i.e. the `build.gradle` file).
32+
* If you are new to Gradle, refer to the [Gradle Tutorial at se-education.org/guides](https://se-education.org/guides/tutorials/gradle.html).
33+
34+
## Testing
35+
36+
### I/O redirection tests
37+
38+
* To run _I/O redirection_ tests (aka _Text UI tests_), navigate to the `text-ui-test` and run the `runtest(.bat/.sh)` script.
39+
40+
### JUnit tests
41+
42+
* A skeleton JUnit test (`src/test/java/seedu/duke/DukeTest.java`) is provided with this project template.
43+
* If you are new to JUnit, refer to the [JUnit Tutorial at se-education.org/guides](https://se-education.org/guides/tutorials/junit.html).
44+
45+
## Checkstyle
46+
47+
* A sample CheckStyle rule configuration is provided in this project.
48+
* If you are new to Checkstyle, refer to the [Checkstyle Tutorial at se-education.org/guides](https://se-education.org/guides/tutorials/checkstyle.html).
49+
50+
## CI using GitHub Actions
51+
52+
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.
53+
54+
## Documentation
55+
56+
`/docs` folder contains a skeleton version of the project documentation.
57+
58+
Steps for publishing documentation to the public:
59+
1. If you are using this project template for an individual project, go your fork on GitHub.<br>
60+
If you are using this project template for a team project, go to the team fork on GitHub.
61+
1. Click on the `settings` tab.
62+
1. Scroll down to the `GitHub Pages` section.
63+
1. Set the `source` as `master branch /docs folder`.
64+
1. Optionally, use the `choose a theme` button to choose a theme for your documentation.

config/checkstyle/checkstyle.xml

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
6+
<!--
7+
Checkstyle configuration that checks the Google coding conventions from Google Java Style
8+
that can be found at https://google.github.io/styleguide/javaguide.html
9+
Checkstyle is very configurable. Be sure to read the documentation at
10+
http://checkstyle.sf.net (or in your downloaded distribution).
11+
To completely disable a check, just comment it out or delete it from the file.
12+
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
13+
-->
14+
15+
<module name = "Checker">
16+
<property name="charset" value="UTF-8"/>
17+
18+
<property name="severity" value="error"/>
19+
20+
<property name="fileExtensions" value="java, properties, xml"/>
21+
<!-- Excludes all 'module-info.java' files -->
22+
<!-- See https://checkstyle.org/config_filefilters.html -->
23+
<module name="BeforeExecutionExclusionFileFilter">
24+
<property name="fileNamePattern" value="module\-info\.java$"/>
25+
</module>
26+
<!-- Checks for whitespace -->
27+
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
28+
<module name="FileTabCharacter">
29+
<property name="eachLine" value="true"/>
30+
</module>
31+
32+
<module name="TreeWalker">
33+
<module name="OuterTypeFilename"/>
34+
<module name="IllegalTokenText">
35+
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
36+
<property name="format"
37+
value="\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
38+
<property name="message"
39+
value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
40+
</module>
41+
<module name="AvoidEscapedUnicodeCharacters">
42+
<property name="allowEscapesForControlCharacters" value="true"/>
43+
<property name="allowByTailComment" value="true"/>
44+
<property name="allowNonPrintableEscapes" value="true"/>
45+
</module>
46+
<module name="LineLength">
47+
<property name="max" value="120"/>
48+
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
49+
</module>
50+
<module name="AvoidStarImport"/>
51+
<module name="OneTopLevelClass"/>
52+
<module name="NoLineWrap"/>
53+
<module name="EmptyBlock">
54+
<property name="option" value="TEXT"/>
55+
<property name="tokens"
56+
value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
57+
</module>
58+
<module name="NeedBraces"/>
59+
<module name="LeftCurly"/>
60+
<module name="RightCurly">
61+
<property name="id" value="RightCurlySame"/>
62+
<property name="tokens"
63+
value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE,
64+
LITERAL_DO"/>
65+
</module>
66+
<module name="RightCurly">
67+
<property name="id" value="RightCurlyAlone"/>
68+
<property name="option" value="alone"/>
69+
<property name="tokens"
70+
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT,
71+
INSTANCE_INIT"/>
72+
</module>
73+
<module name="WhitespaceAround">
74+
<property name="allowEmptyConstructors" value="true"/>
75+
<property name="allowEmptyLambdas" value="true"/>
76+
<property name="allowEmptyMethods" value="true"/>
77+
<property name="allowEmptyTypes" value="true"/>
78+
<property name="allowEmptyLoops" value="true"/>
79+
<message key="ws.notFollowed"
80+
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
81+
<message key="ws.notPreceded"
82+
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
83+
</module>
84+
<module name="OneStatementPerLine"/>
85+
<module name="MultipleVariableDeclarations"/>
86+
<module name="ArrayTypeStyle"/>
87+
<module name="MissingSwitchDefault"/>
88+
<module name="FallThrough"/>
89+
<module name="UpperEll"/>
90+
<module name="ModifierOrder"/>
91+
<module name="EmptyLineSeparator">
92+
<property name="allowNoEmptyLineBetweenFields" value="true"/>
93+
</module>
94+
<module name="SeparatorWrap">
95+
<property name="id" value="SeparatorWrapDot"/>
96+
<property name="tokens" value="DOT"/>
97+
<property name="option" value="nl"/>
98+
</module>
99+
<module name="SeparatorWrap">
100+
<property name="id" value="SeparatorWrapComma"/>
101+
<property name="tokens" value="COMMA"/>
102+
<property name="option" value="EOL"/>
103+
</module>
104+
<module name="SeparatorWrap">
105+
<!-- ELLIPSIS is EOL until https://github.com/google/styleguide/issues/258 -->
106+
<property name="id" value="SeparatorWrapEllipsis"/>
107+
<property name="tokens" value="ELLIPSIS"/>
108+
<property name="option" value="EOL"/>
109+
</module>
110+
<module name="SeparatorWrap">
111+
<!-- ARRAY_DECLARATOR is EOL until https://github.com/google/styleguide/issues/259 -->
112+
<property name="id" value="SeparatorWrapArrayDeclarator"/>
113+
<property name="tokens" value="ARRAY_DECLARATOR"/>
114+
<property name="option" value="EOL"/>
115+
</module>
116+
<module name="SeparatorWrap">
117+
<property name="id" value="SeparatorWrapMethodRef"/>
118+
<property name="tokens" value="METHOD_REF"/>
119+
<property name="option" value="nl"/>
120+
</module>
121+
<module name="PackageName">
122+
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
123+
<message key="name.invalidPattern"
124+
value="Package name ''{0}'' must match pattern ''{1}''."/>
125+
</module>
126+
<module name="TypeName">
127+
<message key="name.invalidPattern"
128+
value="Type name ''{0}'' must match pattern ''{1}''."/>
129+
</module>
130+
<module name="MemberName">
131+
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
132+
<message key="name.invalidPattern"
133+
value="Member name ''{0}'' must match pattern ''{1}''."/>
134+
</module>
135+
<module name="ParameterName">
136+
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
137+
<message key="name.invalidPattern"
138+
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
139+
</module>
140+
<module name="LambdaParameterName">
141+
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
142+
<message key="name.invalidPattern"
143+
value="Lambda parameter name ''{0}'' must match pattern ''{1}''."/>
144+
</module>
145+
<module name="CatchParameterName">
146+
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
147+
<message key="name.invalidPattern"
148+
value="Catch parameter name ''{0}'' must match pattern ''{1}''."/>
149+
</module>
150+
<module name="LocalVariableName">
151+
<property name="tokens" value="VARIABLE_DEF"/>
152+
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
153+
<message key="name.invalidPattern"
154+
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
155+
</module>
156+
<module name="ClassTypeParameterName">
157+
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
158+
<message key="name.invalidPattern"
159+
value="Class type name ''{0}'' must match pattern ''{1}''."/>
160+
</module>
161+
<module name="MethodTypeParameterName">
162+
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
163+
<message key="name.invalidPattern"
164+
value="Method type name ''{0}'' must match pattern ''{1}''."/>
165+
</module>
166+
<module name="InterfaceTypeParameterName">
167+
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
168+
<message key="name.invalidPattern"
169+
value="Interface type name ''{0}'' must match pattern ''{1}''."/>
170+
</module>
171+
<module name="NoFinalizer"/>
172+
<module name="GenericWhitespace">
173+
<message key="ws.followed"
174+
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
175+
<message key="ws.preceded"
176+
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
177+
<message key="ws.illegalFollow"
178+
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
179+
<message key="ws.notPreceded"
180+
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
181+
</module>
182+
<module name="Indentation">
183+
<property name="basicOffset" value="4"/>
184+
<property name="braceAdjustment" value="0"/>
185+
<property name="caseIndent" value="0"/>
186+
<property name="throwsIndent" value="4"/>
187+
<property name="lineWrappingIndentation" value="4"/>
188+
<property name="arrayInitIndent" value="4"/>
189+
</module>
190+
<module name="AbbreviationAsWordInName">
191+
<property name="ignoreFinal" value="false"/>
192+
<property name="allowedAbbreviationLength" value="1"/>
193+
</module>
194+
<module name="OverloadMethodsDeclarationOrder"/>
195+
<module name="VariableDeclarationUsageDistance"/>
196+
<module name="MethodParamPad"/>
197+
<module name="NoWhitespaceBefore">
198+
<property name="tokens"
199+
value="COMMA, SEMI, POST_INC, POST_DEC, DOT, ELLIPSIS, METHOD_REF"/>
200+
<property name="allowLineBreaks" value="true"/>
201+
</module>
202+
<module name="ParenPad"/>
203+
<module name="OperatorWrap">
204+
<property name="option" value="NL"/>
205+
<property name="tokens"
206+
value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR,
207+
LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR, METHOD_REF "/>
208+
</module>
209+
<module name="AnnotationLocation">
210+
<property name="id" value="AnnotationLocationMostCases"/>
211+
<property name="tokens"
212+
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
213+
</module>
214+
<module name="AnnotationLocation">
215+
<property name="id" value="AnnotationLocationVariables"/>
216+
<property name="tokens" value="VARIABLE_DEF"/>
217+
<property name="allowSamelineMultipleAnnotations" value="true"/>
218+
</module>
219+
<module name="NonEmptyAtclauseDescription"/>
220+
<module name="JavadocTagContinuationIndentation"/>
221+
<module name="SummaryJavadoc">
222+
<property name="forbiddenSummaryFragments"
223+
value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
224+
</module>
225+
<module name="JavadocParagraph"/>
226+
<module name="AtclauseOrder">
227+
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
228+
<property name="target"
229+
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
230+
</module>
231+
<module name="JavadocMethod">
232+
<property name="scope" value="public"/>
233+
<property name="allowMissingParamTags" value="true"/>
234+
<property name="allowMissingThrowsTags" value="true"/>
235+
<property name="allowMissingReturnTag" value="true"/>
236+
<property name="allowedAnnotations" value="Override, Test"/>
237+
<property name="allowThrowsTagsForSubclasses" value="true"/>
238+
</module>
239+
<module name="MethodName">
240+
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
241+
<message key="name.invalidPattern"
242+
value="Method name ''{0}'' must match pattern ''{1}''."/>
243+
</module>
244+
<module name="SingleLineJavadoc">
245+
<property name="ignoreInlineTags" value="false"/>
246+
</module>
247+
<module name="EmptyCatchBlock">
248+
<property name="exceptionVariableName" value="expected"/>
249+
</module>
250+
<module name="CommentsIndentation"/>
251+
</module>
252+
</module>

docs/AboutUs.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# About us
2+
3+
Display | Name | Github Profile | Portfolio
4+
--------|:----:|:--------------:|:---------:
5+
![](https://via.placeholder.com/100.png?text=Photo) | John Doe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md)
6+
![](https://via.placeholder.com/100.png?text=Photo) | Don Joe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md)
7+
![](https://via.placeholder.com/100.png?text=Photo) | Ron John | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md)
8+
![](https://via.placeholder.com/100.png?text=Photo) | John Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md)
9+
![](https://via.placeholder.com/100.png?text=Photo) | Don Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md)

0 commit comments

Comments
 (0)