How to create a skeleton of a Java console application

148 views

Published on

Published in: Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
148
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

How to create a skeleton of a Java console application

  1. 1. How to create skeleton of a Java console applicationNotebook: CCP Wiki materialsCreated: 05.06.2012 16:35 Updated: 03.07.2012 19:18Location: Wien, AustriaTags: CCP PD, Система управления страной, ЯваHow to create skeleton of a Java console applicationPrerequisitesFollowing conditions must be satisfied before you can implement the stepsin this tutorial:1) Java 1.6 or better is installed2) Maven 2 or better is installedStep 1Invoke following command on the command linemvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=ru.altruix -DartifactId=populationgeneratorStep 2Create eclipse project files by running following command in the commandline:mvn eclipse:eclipseStep 3 - add checkstyle filesCopy following files into the directory with the pom.xml file of the newproject.1) altruix-checkstyle.java.header2) altruix-checkstyle.sh.header3) altruix-checkstyle.properties.header4) altruix-checkstyle.xml.header5) altruix-checkstyle.xmlStep 4 - add reporting configuration to pom.xmlPaste following text into the pom.xml file. <reporting> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>javancss-maven-plugin</artifactId>
  2. 2. <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>
  3. 3. Step 5 - check that reporting worksCreate 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) Checkstyle2) Cobertura Test Coverage3) CPD report4) FindBugs report5) JavaNCSS report6) JDepend7) PMD ReportStep 6Create a text file called ".gitignore" in the same directory as thepom.xml file.This text file should contain only one line:
  4. 4. targetStep 7 - add compiler configurationPaste 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 dependenciesPaste 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>

×