Step 1: Setup Java, Maven, and SonarQube
1. Java: Latest possible version. Setting up Java, Maven, and eclipse.
2. Maven 3: For building. Setting up Java, Maven, and eclipse.
3. SonarQube: For code quality. SonarQube with Maven Tutorial – Code Quality for Java developers.
4. Jococo SonarQube: For unit test coverage. Jacoco for unit test coverage with SonarQube tutorial.
Step 2: Create a maven project
Press enter for all prompts to use the default values.
1 2 3 |
mvn archetype:generate -DgroupId=com.homeassigment -DartifactId=homeassign-1-test |
Step 3: The pom.xml
Should have the bare minimum dependencies like junit, slf4j, and logback. The SonarQube plugin for code quality. These are necessary to write production quality code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.homeassigment</groupId> <artifactId>homeassign-1-test</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>homeassign-1-test</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <sonar.host.url>http://localhost:9000</sonar.host.url> <logback.version>1.0.0</logback.version> <slf4j.version>1.6.4</slf4j.version> <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin> <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis> </properties> <build> <pluginManagement> <!-- Code Quality Metrics--> <plugins> <plugin> <groupId>org.codehaus.sonar</groupId> <artifactId>sonar-maven-plugin</artifactId> <version>5.3</version> </plugin> </plugins> </pluginManagement> </build> <dependencies> <!-- unit testing--> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <!-- Logging --> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>${logback.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>log4j-over-slf4j</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>${slf4j.version}</version> </dependency> </dependencies> </project> |
Step 4: Create the packages for home assignments
The project structure example used in following home assignments:

pre-interview & self-taught projects Java coding assignments
(Visited 1 times, 1 visits today)