IDE guidelines for the Java Rest API

IDE guidelines

The IDE we have used is Intellij.

We recommend that you install the following plugins:

Plugins used in POM

  • Lombok - Avoids need to write e.g. Getter, Setter, RequiredArgsConstructor, ToString, EqualsAndHashCode) in Java classes.
  • JaCoCo - A free Java code test coverage library.
  • Surefire - Used for reporting purposes (creates reports based on tests in the Java test package).
  • fmt-maven-plugin - Formats the java code based on rules in java-google-style.xml.
  • Spotbugs - Performs a static analysis of the Java code to check for bugs.

Set up the project

How to import the whole project

In the IDE(We used Intellij) go to File -> New -> Project. Set project SDK to Java 11. Click Next -> Next New Project

Choose the java project folder New Java Project click finish.

What setup required to get it up and running

Open up the "java" folder and right click on pom.xml and choose "Add as Maven Project". Click on Run -> Edit Configurations Run Configurations Click on Add new Configuration and choose Application/Spring boot Run Configurations_1 Choose the main class as "Application.java" and under environment set environment variable for AZURE_COSMOSDB_KEY and set JRE to Java 11. Click OK Run Configurations_2

Open Application.java file and right click and choose run Application.Run Java Application

Code Quality

Formatter

Install the intellij-java-google-style.xml formatter configuration file into the IDE from here.

The Java source code will automatically be reformatted to comply with the Google Java Style.

You can override the settings locally in the codebase by adding, for example:

//@formatter:off
manually formatted code
///@formatter:on
Validating and applying formatting

From the <PROJECT-NAME>/java folder run

./mvnw com.coveo:fmt-maven-plugin:check

To validate the current formatting. You can then run the below code to apply formatting to the source code.

./mvnw com.coveo:fmt-maven-plugin:format

Verifying common programming flaws

./mvnw spotbugs:check