YOUR FEEDBACK
The Cloud Wars - Is Guitar Hero a Cloud?
Roland Judas wrote: I am following the cloud discussions for some months n...


2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TOP THREE LINKS YOU MUST CLICK ON


The Maven Build Process
A smooth transition

Digg This!

Page 3 of 3   « previous page

SCM
Maven also provides plug-ins that support various version management systems like CVS, ClearCase, and Subversion. A Maven build can use these plug-ins to automate tasks of files from the version systems based on the tagged version of the project until the deployment components are packaged.

Project Site
Most organizations maintain a list of projects, their stakeholders, and the status on/using portal-based applications. Maven generates a site with project data based on the information provided to it. This site contains details on the project's users, mailing lists, dependencies, and issues tracked and offers a quick project overview.

Maven Build Process Architecture
Let's define a build process architecture based on Maven and a repository product named Artifactory (see Figure 1).

The system and actors represented in the figure are:
1)  Developers: Individuals working to develop a code base for the project using an IDE (such as RAD).
2)  Developer Workstation: The system on which the developers develop, unit test, and build deployable components from the code base as part of the project development lifecycle.
3)  Local Repository: The location (folder) on the developer workstation that caches the dependent artifacts of the project derived from the internal repository during the Maven build.
4)  Maven: An open source build management tool from Apache.
5)  Internal Repository: A centralized repository in an organization used to maintain dependent artifacts for all its projects.
6)  Artifactory: An open source repository management application that provides caching, security, and user-friendly GUIs for managing artifacts. It comes as a WAR application that can be easily deployed and started on any Web container like Apache Tomcat.
7)  CVS Repository: A version management system that manages the project code base and its versions.
8)  Build Server: The system in which the support engineers build projects using the code base from CVS and then execute Maven on it.
9)  Build Engineers: Individuals working on building the project from the code base and deploying the components resulting from Maven's execution on the project to the respective servers.

This process architecture is explained in the context of building a project that will deliver an in-house artifact or reusable component.
1)  The developer creates a new project and defines a folder structure that can either adhere to Maven standards or an organization's own established standards. Note that with non-Maven standards, the POM.xml has to be configured with source directories for Maven to execute.
2)  As part of the development, the developer enhances the code base and defines the project-dependent artifacts in POM.xml.
3)  The developer builds the project using Maven. Maven uses POM.xml as input and executes tasks (prepares resources, compiles, unit tests, packages) according to the build lifecycle set by Maven internally for the artifact. During task execution, Maven resolves the project dependencies first by locating the artifacts in the local repository, or if not there then in the internal or external repositories. Maven caches the dependent artifacts in the local repository when they are first downloaded from the internal or external repositories.
4)  Steps 2 & 3 are repeated until the programmer has finished developing and testing the generated JAR artifacts. He then tags the code base in the version management system and prepares it for release by providing the project name and version information to the build engineers.
5)  Build engineers retrieve the tagged version of the project and prepare to build the project.
6)  Build engineers build the project using Maven and Maven executes the project per the build lifecycle and along the way resolves dependent artifacts from the repositories.
7)  The project build results in the generation of the JAR artifact that will be used across projects and so has to be maintained in the internal repository like other dependent artifacts. Build engineers can use one of the execution tasks in Maven's build lifecycle to deploy the generated JAR artifact to the internal repository. Build engineers can also deploy the artifact to the internal repository manually by uploading it through Artifactory's Web interface.

Case Study - Build a Web Application Project
Let's see how to start and build a Web application project using Maven based on this build process architecture. You need to have Maven and Artifactory installed.

Maven and Artifactory Configuration
The internal repository is managed by Artifactory and deployed in Tomcat. Artifactory has a single configuration file called artifactory.config.xml and following details are configured there:
1)  Local repositories are logical groupings of the artifacts in the repository. Each local repository is defined by a logical name (like Commercial repo, Open source repo) and whether it stores only releases or snapshots.
2)  The remote repository is the external repository and this element is configured with the URL: http://repo1.maven.org.

Maven is configured for downloading artifacts from the internal repository. The configurations for this are done in Settings.xml:
1)  Provide the internal repository URL for artifact releases and snapshots.
2)  Provide the user credentials for these repositories.
3)  Provide proxy server information if the repository server is behind a proxy.

Project Folder Structure
The first most important task before starting project development is to create a folder structure that is meaningful and easy for developers from a build perspective. Maven suggests a directory structure for each type of artifact (JAR, WAR, EAR) or organizations can create folders according to their own standards. The example used here follows Maven's suggested directory structure and refered to the code samples for the layout.

Update POM.xml
It is suggested that Maven projects start with the template POM.xml generated by the Maven plug-ins available for each artifact type. This template POM.xml is located under the project's main folder and is updated as project development progresses. The POM file is mainly enhanced by dependency artifacts, multi-modules during the project lifecycle.

Maven Build Release
Maven projects are built using these commands:

  • 'mvn package' - It packages the deployable component by building from the project source and puts it in the 'target' folder under project root folder.
  • 'mvn install' - It packages the deployable component and installs it in the local repository.
  • 'mvn deploy'- It packages and deploys it in the internal repository.
Reusable artifacts (JARs) generated from projects are deployed in internal repository so that other projects can consume them. So 'mvn deploy' is used by build engineers to deploy them to the internal repository.

For web-based application projects, the generated artifact (WAR) is to be deployed in an application server. So 'mvn package' is used to build the artifact and then build engineers deploy it to the application server.

Convert Existing Projects to Maven-Enabled
When there's an enterprise-wide Maven build process to be implemented, the priorities are:
1)  The existing project structure should not be altered. This is to make sure that the developers/support engineers on the project are at ease; the POM.xml for these projects has to have a 'build' element configured with the appropriate source location.
2)  Smooth transition from the old build process. Developers and support engineers have to be trained on the new build process and its benefits over the old process.
3)  Maven-enable one project at a time without changing the existing code base except for the addition of the POM.xml file. Test the project build after creating the POM file and then implement this build process as part of a production fix or release.

Conclusion
The process architecture detailed here was based on Maven and Artifactory tools to meet the enterprise objective of having a stable build process. The point of choosing Maven, its critical features, and the concept of repositories that help meet the objective were explained. The build process was detailed with actors, tools, and their responsibilities and finally demonstrated by building a sample Web application.

This build process is applicable to most enterprises with slight variations for the organizations' policies and preferences for using an external repository in automated way, the extent of the automation needed, and the use of CruiseControl/Continuum as part of this architecture for continuous builds.


Page 3 of 3   « previous page

About Ravi Muthusubramanian
M.Ravi is a technical architect for the Banking & Capital Markets Division of Infosys. He has almost 8 years of experience in various facets of the software development life cycle and specializes in providing architecture and design solutions based on broad of spectrum of technologies including JEE, SOA, Message Broker, SAS and CRM.

LATEST JAVA STORIES & POSTS
Saving Your Investment: Transforming J2EE applications into Web 2.0 using GWT
The pressure is on to keep pace with Web 2.0 entrants into the marketplace. Rewriting is expensive; adding AJAX widgets results in a complex, unmaintainable application. Both require you to hire scarce JavaScript developers. Google Web Toolkit -- the SDK that allows you to write
WSRP Really Works! - Part 2
A standard from OASIS called Web Services for Remote Portlets (WSRP) is used so portlets can be decoupled from a portal. In part one (JDJ, Volume. 13, issue 3) of this article, we introduced the relevant standards and specifications and then demonstrated WSRP's capabilities by co
Adobe's Kevin Lynch and Microsoft's Scott Guthrie to Keynote AJAX World RIA Conference & Expo
Two of the biggest launches in Rich Internet Application history took place in 2007/2008 when Adobe launched AIR 1.0 in February '08 and Microsoft launched Silverlight (September '07). At the 6th International AJAXWorld RIA Conference & Expo in October SYS-CON Events is delighted
Sun Expects Q4 Earnings Above Estimates
On Tuesday evening Sun issued a fourth-quarter guidance range largely above analysts' estimates. The company pre-announced that revenue for its fiscal fourth quarter ended June was $3.725 billion to $3.8 billion, with gross margin in the 44-45% range. Sun expects non-GAAP profits
Virtualization Conference Keynote Webcast Live on SYS-CON.TV
Brian Stevens, the Chief Technology Officer and Vice President of Engineering of Red Hat, delivered his Virtualization Keynote 'The Future of the Virtual Enterprise' at SYS-CON's Virtualization Conference & Expo 2007 West in San Francisco. 'Virtualization is the hottest subject
The Beauty of JavaScript
JavaScript is one of the most interesting and misunderstood programming languages in common use today. Most developers will go their entire careers without realizing its full potential. It's not often that you get a language that supports the feature set that JavaScript does, whi
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

SPONSORED BY INFRAGISTICS
SOA in a JVM: OSGi Service Platform - A Dynamic Component System for Java
There are many forces that influence technological evolution. After a decade of building enterprise
AJAX and Enterprise RIA Tools - JSF, Flex, and JavaFX
2008 is going to be an important year for Rich Internet Applications. Most organizations are deliver
Final Voting Phase on OpenAjax Browser Wishlist
The OpenAjax Alliance is developing an Ajax industry wishlist for future browsers, using a dedicated
AJAX World RIA Conference News - Netflix UI Guru To Present on Crafting Rich Web Interfaces
In every field of design one of the first things students do is learn from the work of others. They
Infragistics Releases CTP UI Components for Microsoft Silverlight Beta 2
Infragistics announced the availability of two Community Technology Preview (CTP) User Interface (UI
Yahoo User Interface 2.5.2 Released
The YUI development team has released version 2.5.2; you can download the new release from SourceFor
ADS BY GOOGLE
BREAKING JAVA NEWS
Domark International, Inc. Completes Its Acquisition of Javaco, Inc.
Domark International, Inc. (OTCBB:DOMK) announced today that it has completed its acqui