Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Create Java console app skeleton
1. How to create skeleton of a Java console application
Notebook: CCP Wiki materials
Created: 05.06.2012 16:35 Updated: 03.07.2012 19:18
Location: Wien, Austria
Tags: CCP PD, Система управления страной, Ява
How to create skeleton of a Java console application
Prerequisites
Following conditions must be satisfied before you can implement the steps
in this tutorial:
1) Java 1.6 or better is installed
2) Maven 2 or better is installed
Step 1
Invoke following command on the command line
mvn archetype:generate
-DarchetypeGroupId=org.apache.maven.archetypes
-DgroupId=ru.altruix
-DartifactId=populationgenerator
Step 2
Create eclipse project files by running following command in the command
line:
mvn eclipse:eclipse
Step 3 - add checkstyle files
Copy following files into the directory with the pom.xml file of the new
project.
1) altruix-checkstyle.java.header
2) altruix-checkstyle.sh.header
3) altruix-checkstyle.properties.header
4) altruix-checkstyle.xml.header
5) altruix-checkstyle.xml
Step 4 - add reporting configuration to pom.xml
Paste following text into the pom.xml file.
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javancss-maven-plugin</artifactId>
3. Step 5 - check that reporting works
Create reports using "mvn site" command.
Thereafter, open the file target/site/index.html.
It should look like this:
When you click on "Project reports", you should see following:
Following reports must be present:
1) Checkstyle
2) Cobertura Test Coverage
3) CPD report
4) FindBugs report
5) JavaNCSS report
6) JDepend
7) PMD Report
Step 6
Create a text file called ".gitignore" in the same directory as the
pom.xml file.
This text file should contain only one line:
4. target
Step 7 - add compiler configuration
Paste following code at the correct place in the pom.xml file:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</build>
Step 8 - add altruix-commons and logging dependencies
Paste following code at the correct place in the pom.xml file:
<dependencies>
...
<dependency>
<groupId>ru.altruix</groupId>
<artifactId>commons</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>0.9.26</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>0.9.26</version>
</dependency>
...
</dependencies>
Step 9 - change version of JUnit
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>