วันอังคารที่ 23 พฤศจิกายน พ.ศ. 2553

Java Development with NetBeans and Maven: Part 5

Overview

I hope we are well prepared for moving further to the very powerful “Maven” features, which we have known before, the “site”, especially the “report” integration to the outer world. There are many powerful “Maven Plug-in” provided by the “Maven” itself. You can see further information here. From now on, I will introduce you the “Reporting Plug-ins”.

The Report Plug-ins

Regarding the “Maven Plug-inhere, you may be noticed that there are two plug in which we used before. Guess what? The “project-info-reports”, the “mvn site” command itself and the “surefire-report”, the testing report for our previous JUnit. You already know how easy it is. The rest plug in also be same for sure. One picture can give us a thousand words. Here is my tested template "Project POM File" (pom.xml). Please feel free to modify it so that it is fit for your environment.








001 

002 <project xmlns="http://maven.apache.org/POM/4.0.0" 

003 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

004 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 

005 http://maven.apache.org/maven-v4_0_0.xsd">

006     <modelVersion>4.0.0</modelVersion>

007     <groupId>com.scc.maven.java</groupId>

008     <artifactId>MavenJavaPrj01</artifactId>

009     <packaging>jar</packaging>

010     <version>1.0-SNAPSHOT</version>

011     <name>MavenJavaPrj01</name>

012     <url>The Project web site URL</url>

013     <description>The SDLC Learning</description>

014 

015     <licenses>

016         <license>

017             <name>Apache 2</name>

018             <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>

019             <distribution>repo</distribution>

020             <comments>A business-friendly OSS license</comments>

021         </license>

022     </licenses>

023 

024     <organization>

025         <name>The Organization Name</name>

026         <url>The Organization web site URL</url>

027     </organization>

028 

029     <developers>

030         <developer>

031             <id>The developer id</id>

032             <name>The developer name</name>

033             <email>The developer email</email>

034             <url>The developer web site URL</url>

035             <organization>The developer organization</organization>

036             <organizationUrl>The organization web site url</organizationUrl>

037             <roles>

038                 <role>Role #1</role>

039                 <role>Role #2</role>

040             </roles>

041             <timezone>+7</timezone>

042             <properties>

043                 <picUrl>The developer picture URL</picUrl>

044             </properties>

045         </developer>

046     </developers>

047 

048     <issueManagement>

049         <system>The issue management system, e.g. Bugzilla, TestTrack, 

050         ClearQuest, etc</system>

051         <url>The issue management system web site URL</url>

052     </issueManagement>

053 

054     <ciManagement>

055         <system>The CI management system, e.g. Hudson,continuum, etc</system>

056         <url>The CI web site URL</url>

057         <notifiers>

058             <notifier>

059                 <type>mail</type>

060                 <sendOnError>true</sendOnError>

061                 <sendOnFailure>true</sendOnFailure>

062                 <sendOnSuccess>false</sendOnSuccess>

063                 <sendOnWarning>false</sendOnWarning>

064                 <configuration>

065                     <address>The sender email address</address>

066                 </configuration>

067             </notifier>

068         </notifiers>

069     </ciManagement>

070 

071     <scm>

072         <connection>scm:svn:Path/To/Repository</connection>

073         <developerConnection>scm:svn:Path/To/Repository</developerConnection>

074         <tag>HEAD</tag>

075         <url>The SCM web site URL</url>

076     </scm>

077 

078     <prerequisites>

079         <maven>2.2.1</maven>

080     </prerequisites>

081 

082     <build>

083         <plugins>

084             <plugin>

085                 <groupId>org.apache.maven.plugins</groupId>

086                 <artifactId>maven-compiler-plugin</artifactId>

087                 <version>2.0.2</version>

088                 <configuration>

089                     <source>1.6</source>

090                     <target>1.6</target>

091                     <encoding>${project.build.sourceEncoding}</encoding>

092                 </configuration>

093             </plugin>

094             <plugin>

095                 <groupId>org.apache.maven.plugins</groupId>

096                 <artifactId>maven-resources-plugin</artifactId>

097                 <version>2.2</version>

098                 <configuration>

099                     <encoding>${project.build.sourceEncoding}</encoding>

100                 </configuration>

101             </plugin>

102             <plugin>

103                 <groupId>org.apache.maven.plugins</groupId>

104                 <artifactId>maven-surefire-plugin</artifactId>

105                 <version>2.6</version>

106                 <configuration>

107                     <encoding>${project.build.sourceEncoding}</encoding>

108                     <includes>

109                         <include>

110                             **/*TestSuite*.java

111                         </include>

112                     </includes>

113                 </configuration>

114             </plugin>

115             <plugin>

116                 <groupId>org.apache.maven.plugins</groupId>

117                 <artifactId>maven-site-plugin</artifactId>

118                 <version>2.1.1</version>

119                 <configuration>

120                     <locales>en</locales>

121                 </configuration>

122             </plugin>

123         </plugins>

124         <resources>

125             <resource>

126                 <directory>${basedir}/src/main/java</directory>

127                 <includes>

128                     <include>log4j.dtd</include>

129                     <include>log4j.xml</include>

130                 </includes>

131             </resource>

132         </resources>

133     </build>

134     <reporting>

135         <plugins>

136             <plugin>

137                 <groupId>org.apache.maven.plugins</groupId>

138                 <artifactId>maven-project-info-reports-plugin</artifactId>

139                 <version>2.2</version>

140             </plugin>

141 

142             <plugin>

143                 <groupId>org.apache.maven.plugins</groupId>

144                 <artifactId>maven-surefire-report-plugin</artifactId>

145                 <version>2.6</version>

146             </plugin>

147             <plugin>

148                 <groupId>org.apache.maven.plugins</groupId>

149                 <artifactId>maven-changelog-plugin</artifactId>

150                 <version>2.2</version>

151                 <configuration>

152                     <username>${svnUser}</username>

153                     <password>${svnPassword}</password>

154                 </configuration>

155             </plugin>

156             <plugin>

157                 <groupId>org.apache.maven.plugins</groupId>

158                 <artifactId>maven-checkstyle-plugin</artifactId>

159                 <version>2.6</version>

160                 <configuration>

161                     <configLocation>config/sun_checks.xml</configLocation>

162                 </configuration>

163             </plugin>

164             <plugin>

165                 <groupId>org.apache.maven.plugins</groupId>

166                 <artifactId>maven-javadoc-plugin</artifactId>

167                 <version>2.7</version>

168                 <configuration>

169                     <stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css

170                     </stylesheetfile>

171                     <show>private</show>

172                 </configuration>

173             </plugin>

174             <plugin>

175                 <groupId>org.apache.maven.plugins</groupId>

176                 <artifactId>maven-jxr-plugin</artifactId>

177                 <version>2.2</version>

178                 <configuration>

179                     <linkXref>true</linkXref>

180                     <sourceEncoding>utf-8</sourceEncoding>

181                     <minimumTokens>100</minimumTokens>

182                     <targetJdk>1.5</targetJdk>

183                     <excludes>

184                         <exclude>**/*Bean.java</exclude>

185                         <exclude>**/generated/*.java</exclude>

186                     </excludes>

187                     <excludeRoots>

188                         <excludeRoot>target/generated-sources/stubs</excludeRoot>

189                     </excludeRoots>

190                 </configuration>

191             </plugin>

192             <plugin>

193                 <groupId>org.apache.maven.plugins</groupId>

194                 <artifactId>maven-pmd-plugin</artifactId>

195                 <version>2.5</version>

196             </plugin>

197 

198         </plugins>

199     </reporting>

200     <dependencies>

201         <dependency>

202             <groupId>junit</groupId>

203             <artifactId>junit</artifactId>

204             <version>4.8.2</version>

205             <scope>test</scope>

206         </dependency>

207         <dependency>

208             <groupId>log4j</groupId>

209             <artifactId>log4j</artifactId>

210             <version>1.2.16</version>

211             <scope>compile</scope>

212         </dependency>

213     </dependencies>

214     <properties>

215         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

216     </properties>

217 </project>





How the report is created.

It is simple by using the “mvn site” command, please refer to my previous post.

Are there any outer world plug in?

Yes, sure. Why not? Maven also mentioned in their plug in page as well. Please travel to the lower part of that page you will see the outer world for sure. I hope we are enjoy traveling.

Summary

We have finished preparing our development environment so that we can ensure that there should not be any surprise during the integration with the very powerful “Maven” features, the “site”, especially the “report”. As I've mentioned, This is a final article for my first series.
The well preparing will help us to reduce the defect, on the other hand, if the defect is less, the working time is less, too. That mean we will have more time to do other things in my life. For me is writing this blog. Next I will move further to the detailed “Java/JavaEE” development with “Maven” and will do my best to post for sure. Please stay tuned as always.

ไม่มีความคิดเห็น:

แสดงความคิดเห็น