Upload
soaring-eagle-llc
View
471
Download
1
Tags:
Embed Size (px)
Citation preview
Maven Overview
Great West LifeScott Ryan
Soaring Eagle, LLCJanuary 29, 2008
Agenda
• What is Maven?• Projects and the project model• XML Configuration files• Repositories• Plug-ins• Reporting• Automated Builds and Quality Control• Release Management
What is Maven
• A Build System• Favors convention over configuration or customization• Supports standardized artifact management and
auditing• Supports reporting, code quality and automated builds• Supports release automation• Used by very large enterprises• Has a well defined life-cycle
Sample Life-cycle
• validate• compile• test• package• integration test• verify • install• deploy
Repositories
• Multi-level repository modelo Increases performanceo Insures consistency between all builds in an
enterpriseo Enables granular securityo Enables quick project jump-start and enrichment
Repository Diagram
Project ARepository
LocalRepository
Enterprise/ProxyRepository
Project BRepository
CommercialRepository
Remote Repository
Remote Repository
Remote Repository
Projects and the Project Model
• Project structure is important• Project definition is controlled by the Project POM• Maven encourages a best practice model but supports
almost any model• Project isolates components such as test and delivery
resources to ease packaging and increase security• Following the default project structure eases the use
of plug-ins and standard reporting
Project Layout
• See Demo
XML Configuration Files
• settings.xmlo Unique Schemao Supports cross project configuration
• pom.xmlo Unique Schemao Describes the structure of a projecto Can be logically or physically hierarchical or botho Controls the behavior of the maven systemo Allows for transitive dependency resolutiono The mother or master pom is the parent of all poms
Suggested Structure
• settings.xmlo repository definitiono server security information for deploymento local repository location information
• Enterprise Pomo Common plug-in definitionso Common profileso Dependency definitionso Common reportso Site configuration information
Suggested Structure
(2)()
• Project Pomo Dependency version informationo Project version informationo Common propertieso Common profile informationo Module definitions
• Module Pomo Specific module dependencieso Module type information (jar, etc)o Module resource definitionso Specific profile informationo Module properties
Project Creation
mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-jsf -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.1 -DgroupId=com.mycompany.app -DartifactId=myproject
settings.xml
<settings><servers><server><id>codehaus.org</id><username>guessme</username><password>guessme</password></server></servers>PROFILE SECTION GOES HERE. SEE NEXT SLIDE<activeProfiles><activeProfile>dev</activeProfile></activeProfiles><pluginGroups><pluginGroup>org.appfuse</pluginGroup><pluginGroup>org.codehaus.mojo</pluginGroup>
</pluginGroups></settings>
settings.xml(2)
<profiles><profile><id>dev</id><repositories><repository><id>Codehaus Snapshots</id><url>http://snapshots.repository.codehaus.org/</url><snapshots><enabled>true</enabled></snapshots><releases><enabled>false</enabled></releases></repository></repositories><pluginRepositories><pluginRepository><id>Codehaus Snapshots</id><url>http://snapshots.repository.codehaus.org/</url><snapshots><enabled>true</enabled></snapshots><releases><enabled>false</enabled></releases></pluginRepository></pluginRepositories></profile></profiles>
pom.xml
• See text fileo Discuss dependencieso Discuss Plugin configurationo Discuss properties
Profiles
• Allow custom configuration• Triggered by build flags• Use should be minimized to lower impact on SOX
compliance• Can be used for environment specific configuration• Can be combined in one build and are assembled in
order
Profile Sample
<profile><id>jboss</id><!-- Add el-api dependency since JBoss 4.0.5 uses Tomcat 5.5.x and JBoss 4.2.0 doesn't work with Cargo --><dependencies><dependency><groupId>javax.el</groupId><artifactId>el-api</artifactId><version>${el.version}</version></dependency></dependencies><properties><cargo.container>jboss4x</cargo.container><cargo.container.home>${env.JBOSS_HOME}</cargo.container.home><cargo.container.url>http://easynews.dl.sourceforge.net/sourceforge/jboss/jboss-4.0.5.GA.zip</cargo.container.url></properties></profile>
Resources
• Resources are assembled during the build• Resources can be configured using profiles• Resources can use the replacement process• Alteration of resources should be discouraged due to
SOX compliance• Location and destination of resources files is life-cycle
and plug-in dependent• Configured via the pom
Plug-ins(Mojo’s)
• Plug-ins modify or enhance the behavior of the Maven system
• Plug-ins are external to the maven system• Plug-ins can be written in many languages but are
usually provided by outside parties• Plug-ins align with the life-cycle• Plug-ins can be configured in the settings.xml and the
pom.xml• Maven is build primarily of plug-ins
Plug-ins
• Java (war, ejc, ear, rar, etc.)• Assembly• IDE (Eclipse, Intelli-J, NetBeans)• SCM (CVS, SVN, PCVS, Perforce, etc.)• Code Quality (Checkstyle, PMD, Findbugs, JDepend,
SCM)• Deployment (Weblogic, Tomcat, Jetty)• Testing (JUnit, Cobertura)• Generation (XDoclet, Hibernate, Castor, XMLBeans)
Reporting
• Report generation is supported via plug-ins• Maven generates a standalone site for report
organization• Sites follow a standard layout but is highly
customizable• Maven supplies many core reports
Report Samples
• See live Demo
Automated Builds
• Maven offers easy integration with standard build systemso Continuumo Cruise Controlo Anthill
• Maven eases the addition of new projects by its consistency
Release Management
• Maven provides consistent predictable low impact release management
• This process insures a repeatable process with high likelihood of success
• Process is highly automated and mostly hands off• Output is a file describing the exact process and hot to
recreate that process without manual intervention• Support checkpoint restarts• Great for SOX compliance
Release(Prepare)
• Check for snapshot dependencies• Check for SCM updates and missed checkins• Build and test the latest code• Update and commit poms to reflect new release• Create SCM branch• Update and commit poms to reflect new snapshot• Output file to recreate build with new branch
Release(Perform)
• Leverages file created in prepare step• Obtains code from the branch to a new directory• Builds with proper flags or additional flags• Installs or deploys artifacts to proper repositories• Updates site information is desired• Destroys the build file when successful (Make a
backup)