|
YOUR FEEDBACK Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP THREE LINKS YOU MUST CLICK ON Development An Introduction to Maven - Part III
Application development management using Maven 2 and Eclipse
Sep. 1, 2007 05:00 AM
In the parts 1 and 2 of this article, we demonstrated how to download and install Maven 2, how to install the Maven 2 plugin for Eclipse, and how to go about setting up a project directory structure using Maven 2. We used a simple use case for displaying employee details on the Web given an employee ID, but deliberately made the design a bit complex by introducing design concepts such as XML binding, EJBs, and JCA connectors to illustrate a few of the many features offered by Maven. In this final installment of the article, we continue with the remaining modules in our example and illustrate a few more developmental tasks that can be accomplished fairly easily using Maven that otherwise would demand significant time and effort to accomplish.
1. In the Eclipse 'Package Explorer' pane, right-click on the 'connector' module's POM file and in the menu, select 'Add Dependency' Maven2 option as shown in Figure 1. <project> It's time to add connector implementation Java classes. The source files that we developed for the connector are shown in Figure 4. Download and review the source files to understand the complete implementation. However, the important classes to note are 'EmployeeInfoCCIConnection,' 'EmployeeInfoCCIInteraction,' and 'EmployeeInfoSPIManagedConnection.' The sequence diagram as shown in Figure 5 gives a high-level view of the method calls that a client will invoke to retrieve employee information using an employee ID. For brevity's sake, the sequence diagram is kept simple. The RAR artifact for the 'connector' module can be created by adding 'maven-rar-plugin.' By default, this plug-in will look for RAR meta-information such as the 'ra.xml' descriptor file under the 'src/main/rar/META-INF' directory. The 'ra.xml' descriptor is in Listing 1. Static Analysis of Code using Maven PMD is a static analysis tool for Java code. PMD packages a number of ready-to-run rules that can identify unused variables, unnecessary object creation, and empty catch blocks in the source code. Custom rules can also be incorporated. PMD can be executed using Maven by including 'maven-pmd-plugin' in the POM file as shown in the following snippet. The PMD plug-in lets you automatically run the PMD code analysis tool on your project's source code and generate a site report with its results. For more information on the PMD Maven plug-in, refer to plug-in documentation available at http://maven.apache.org/plugins/maven-pmd-plugin/. <plugin> PMD plug-in can be invoked at the command line within the module directory by running the command below. However, with the current implementation, the plug-in will generate reports only in case of 'jar,' 'war,' and 'ejb' POM packaging types. Since the current POM is a 'rar' packaging type, the packaging type should be temporarily changed to 'jar' so that PMD plug-in can generate the reports. mvn pmd:pmd When this command is executed after temporarily changing the packaging type to 'jar,' Maven will invoke the PMD plug-in that will run the code analysis and create reports under the 'target/site' directory with the main report in the 'pmd.html' file. Figure 6 is the report generated for the 'connector' module source code. Make sure to reset the packaging type back to 'rar.' YOUR FEEDBACK
LATEST JAVA STORIES & POSTS
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK SPONSORED BY INFRAGISTICS
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||