how to create a skeleton of a java console application
TRANSCRIPT
NNNNooootttteeeebbbbooooooookkkk:::: CCP Wiki materials
CCCCrrrreeeeaaaatttteeeedddd:::: 05.06.2012 16:35 UUUUppppddddaaaatttteeeedddd:::: 03.07.2012 19:18
LLLLooooccccaaaattttiiiioooonnnn:::: Wien, Austria
TTTTaaaaggggssss:::: CCP PD, Система управления страной, Ява
How to create skeleton of a Java console application
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>
<version>2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<targetJdk>1.7</targetJdk>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.6</version>
<configuration>
<configLocation>altruix-
checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-
plugin</artifactId>
<version>2.0.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.2</version>
<configuration>
<inputEncoding>UTF-8</inputEncoding>
<outputEncoding>UTF-8</outputEncoding>
<locales>en,ru</locales>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.0.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
</plugin>
</plugins>
</reporting>
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:
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>