26
Maven Overview Great West Life Scott Ryan Soaring Eagle, LLC January 29, 2008

Maven Overview January 2008

Embed Size (px)

Citation preview

Page 1: Maven Overview January 2008

Maven Overview

Great West LifeScott Ryan

Soaring Eagle, LLCJanuary 29, 2008

Page 2: Maven Overview January 2008

Agenda

• What is Maven?• Projects and the project model• XML Configuration files• Repositories• Plug-ins• Reporting• Automated Builds and Quality Control• Release Management

Page 3: Maven Overview January 2008

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

Page 4: Maven Overview January 2008

Sample Life-cycle

• validate• compile• test• package• integration test• verify • install• deploy

Page 5: Maven Overview January 2008

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

Page 6: Maven Overview January 2008

Repository Diagram

Project ARepository

LocalRepository

Enterprise/ProxyRepository

Project BRepository

CommercialRepository

Remote Repository

Remote Repository

Remote Repository

Page 7: Maven Overview January 2008

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

Page 8: Maven Overview January 2008

Project Layout

• See Demo

Page 9: Maven Overview January 2008

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

Page 10: Maven Overview January 2008

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

Page 11: Maven Overview January 2008

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

Page 12: Maven Overview January 2008

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

Page 13: Maven Overview January 2008

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>

Page 14: Maven Overview January 2008

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>

Page 15: Maven Overview January 2008

pom.xml

• See text fileo Discuss dependencieso Discuss Plugin configurationo Discuss properties

Page 16: Maven Overview January 2008

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

Page 17: Maven Overview January 2008

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>

Page 18: Maven Overview January 2008

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

Page 19: Maven Overview January 2008

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

Page 20: Maven Overview January 2008

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)

Page 21: Maven Overview January 2008

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

Page 22: Maven Overview January 2008

Report Samples

• See live Demo

Page 23: Maven Overview January 2008

Automated Builds

• Maven offers easy integration with standard build systemso Continuumo Cruise Controlo Anthill

• Maven eases the addition of new projects by its consistency

Page 24: Maven Overview January 2008

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

Page 25: Maven Overview January 2008

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

Page 26: Maven Overview January 2008

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)