From d6ade39ab6da799f0357b2f9477addd76f2f3942 Mon Sep 17 00:00:00 2001 From: Martin Choo Date: Sat, 22 Oct 2016 17:07:07 +0800 Subject: [PATCH] [#156] Document checkstyle use (#157) * Added checkstyle plugin for eclipse and add some documentation on how to use it. * Attempted to fix invalid values in checkstyle configuration. Added more detailed instructions to setup checkstyle after project import. * Added localised checkstyle-related files to gitignore. * Removed eclipse plugin settings files. * Added tip to click on the text again after selection. --- .classpath | 2 +- .gitignore | 2 ++ .project | 26 ++++++++++++++++++++++ .settings/org.eclipse.buildship.core.prefs | 11 --------- config/checkstyle/checkstyle.xml | 12 +--------- docs/DeveloperGuide.md | 14 +++++++++++- docs/UsingGradle.md | 11 +++++++++ 7 files changed, 54 insertions(+), 24 deletions(-) delete mode 100644 .settings/org.eclipse.buildship.core.prefs diff --git a/.classpath b/.classpath index 3f05f311a90b..c59a5284f736 100644 --- a/.classpath +++ b/.classpath @@ -15,7 +15,7 @@ - + diff --git a/.gitignore b/.gitignore index 45a20de82e87..d74f000fd0e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ build/ .gradle/ +.checkstyle +.settings/ .idea/ lib/* *.iml diff --git a/.project b/.project index 1c9339c5f927..18f57e9ae6ac 100644 --- a/.project +++ b/.project @@ -15,9 +15,35 @@ + + net.sf.eclipsecs.core.CheckstyleBuilder + + + org.eclipse.buildship.core.gradleprojectnature org.eclipse.jdt.core.javanature + net.sf.eclipsecs.core.CheckstyleNature + + + 1476898072165 + + 26 + + org.eclipse.ui.ide.multiFilter + 1.0-projectRelativePath-matches-false-false-build + + + + 1476898072188 + + 26 + + org.eclipse.ui.ide.multiFilter + 1.0-projectRelativePath-matches-false-false-.gradle + + + diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index 4e0fc71ac89f..000000000000 --- a/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -build.commands=org.eclipse.jdt.core.javabuilder -connection.arguments= -connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) -connection.gradle.user.home=null -connection.java.home=null -connection.jvm.arguments= -connection.project.dir= -derived.resources=.gradle,build -eclipse.preferences.version=1 -natures=org.eclipse.jdt.core.javanature -project.path=\: diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 032a3b1c4abb..c786caa1b993 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -124,18 +124,8 @@ - + - - - - diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 4b91881267ee..c8fb444cfc2e 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -25,6 +25,7 @@ 3. **e(fx)clipse** plugin for Eclipse (Do the steps 2 onwards given in [this page](http://www.eclipse.org/efxclipse/install.html#for-the-ambitious)) 4. **Buildship Gradle Integration** plugin from the Eclipse Marketplace +5. **Checkstyle Plug-in** plugin from the Eclipse Marketplace #### Importing the project into Eclipse @@ -42,6 +43,17 @@ (This is because Gradle downloads library files from servers during the project set up process) > * If Eclipse auto-changed any settings files during the import process, you can discard those changes. +#### Configuring Checkstyle +1. Click `Project` -> `Properties` -> `Checkstyle` -> `Local Check Configurations` -> `New...` +2. Choose `External Configuration File` under `Type` +3. Enter an arbitrary configuration name e.g. addressbook +4. Import checkstyle configuration file found at `config/checkstyle/checkstyle.xml` +5. Click OK once, go to the `Main` tab, use the newly imported check configuration. +6. Tick and select `files from packages`, click `Change...`, and select the `resources` package +7. Click OK twice. Rebuild project if prompted + +> Note to click on the `files from packages` text after ticking in order to enable the `Change...` button + #### Troubleshooting project setup **Problem: Eclipse reports compile errors after new commits are pulled from Git** @@ -255,7 +267,7 @@ Here are the steps to create a new release. 1. Generate a JAR file [using Gradle](UsingGradle.md#creating-the-jar-file). 2. Tag the repo with the version number. e.g. `v0.1` - 2. [Crete a new release using GitHub](https://help.github.com/articles/creating-releases/) + 2. [Create a new release using GitHub](https://help.github.com/articles/creating-releases/) and upload the JAR file your created. ### Managing Dependencies diff --git a/docs/UsingGradle.md b/docs/UsingGradle.md index 578c5f8634c2..4eac109ce89d 100644 --- a/docs/UsingGradle.md +++ b/docs/UsingGradle.md @@ -47,6 +47,17 @@ If we package only our own class files into the JAR file, it will not work prope Therefore, we package all dependencies into a single JAR files, creating what is also known as a _fat_ JAR file. To create a fat JAR fil, we use the Gradle plugin [shadow jar](https://github.com/johnrengelman/shadow). +## Running code style checks + +* **`checkstyleMain`**
+ Runs the code style check for the main code base + +* **`checkstyleTest`**
+ Runs the code style check for the test code base + +The set of code style rules implemented can be found in `config/checkstyle/checkstyle.xml`. +To enable _exceptions_ to code styles, add in the comment `//CODESTYLE.OFF: RuleName` at the start of the section and `//CODESTYLE.ON: RuleName` at the end of the section. + ## Running Tests * **`allTests`**