maven overview part i denver java user's group and denver bea user's group jan 2006
DESCRIPTION
Part 1 of an overview of the Maven build systemTRANSCRIPT
Soaring Eagle L.L.C
Maven OverviewPart 1
Denver JBOSS User’s GroupJanuary 2006Scott Ryan
Soaring Eagle L.L.C
Agenda
• Why Maven?• Maven 101• Deployments with Maven• Maven integrations• Maven in the enterprise• Maven 1.0 versus 2.0• Demo
Soaring Eagle L.L.C
Agenda
• Why Maven?• Maven 101• Deployments with Maven• Maven integrations• Maven in the enterprise• Maven 1.0 versus 2.0• Demo
Soaring Eagle L.L.C
Analogy: How to develop an application?
My Application
Frameworks
Solution 1
My Application
Solution 2
Container
E.g. Application Server, Eclipse RCP, Net beans, etc
API
Services
Soaring Eagle L.L.C
Maven Objectives
• Make the build process easy • Provide a uniform build system • Provide quality project information • Provide guidelines for best practices
development • Allow transparent migration to new features
Soaring Eagle L.L.C
How to develop a build?
My Build
Ant tasks
Solution 1: Ant
My Build
Solution 2: Maven
Maven (Container)Task calls
Goals/Plug-ins
« Maven is a build container »
Soaring Eagle L.L.C
Advantages of a Container Approach
• Ability to reuse existing serviceso More than 100 existing Maven plug-ins (jar, cactus,
clover, JIRA, site, dashboard, etc)• Easy to get started
o Just need to configure and extend• Ability to benefit from new services simply by
upgrading• Well-defined and shared structure/architecture
Soaring Eagle L.L.C
Advantages (Cont.)
• Easier to maintaino Knowledgeable resources on the marketo Well-defined structure
• It makes sense to use a custom approach when flexibility is a musto This is not usually the case for builds
Soaring Eagle L.L.C
Agenda
• Why Maven?• Maven 101• Deployments with Maven• Maven integrations• Maven in the enterprise• Maven 1.0 versus 2.0• Demo
Soaring Eagle L.L.C
Current Versions
• Maven 1o 1.0.2 and 1.1-beta-2o maven commando Cut your teeth here and don’t worry about the beta label
• Maven 2o 2.0.1o mvn commando Can run side by side
Soaring Eagle L.L.C
Maven 101
• Maven in 3 concepts:o POM (Project Object Model)o Plug-ins
Made of Goals = Actionso Repositories
• Maven files (1.0)o project.xml
POM (Project Object Model)o maven.xml
Custom goals in Jelly Goal, pre-Goal, post-Goal
o project.properties Runtime Configuration
o build.properties Runtime Configuration
Soaring Eagle L.L.C
Maven (2.0) Project Layout
Soaring Eagle L.L.C
POM (1.0) example (1/2)
Soaring Eagle L.L.C
POM (1.0) example (2/2)
Soaring Eagle L.L.C
Project lifecycle with Maven (1.0) plug-ins (1/2)
Prepare Project Compile/ArchiveUnit tests
Quality checks
- Genapp- JBuilder- Idea- JDeveloper- Eclipse- Scm
- Java- Jar- War- Ejb- Ear- Rar- Uberjar- XDoclet- Test- AspectJ
- Checkstyle- PMD- Findbugs- Clover- Emma- JCoverage- JDepend- Ncss- Patterntesting
1 2 3
Soaring Eagle L.L.C
Project lifecycle with Maven(1.0) plug-ins (2/2)
EnvironmentDeployment
Functional tests
Site/ReportGeneration
Deployment
- JBoss- WebSphere- WebLogic- Jetty- Cactus- Latka- HttpUnit- Abbot- (Cargo)
- Site• Changes• Jira• Dashboard• Changelog• File activity
- Developer activity
• StatCvs
- Site- Dist- Artifact- War/Ejb/Ear/Jar...- Scm- Nsis- (Cargo)
4 5 6
Soaring Eagle L.L.C
Maven 2.0 lifecycle (1)
• validate• generate-sources• process-sources • generate-resources • process-resources• compile• process-classes• post-process
Soaring Eagle L.L.C
Maven 2.0 Lifecycle (2)
• generate-test-sources• process-test-sources• generate-test-resources• process-test-resources• test-compile• test• package
Soaring Eagle L.L.C
Maven 2.0 lifecycle (3)
• before-integration-test• integration-test• after-integration-test• verify• install• deploy
Soaring Eagle L.L.C
Value of a repository structure
• Multiple Levels including environment specific (Dev, QA, Stage, Production)
• Contains Versioned resources• Can control external library usage• Logical Organization of artifacts• Speeds builds using build once philosophy• Provides audit trail (record of build components)• Multilevel security
Soaring Eagle L.L.C
Maven Repositories
Maven coreRemote
Repository
Web Server
LocalRepository
project.xml (POM)
1
2
3
4
JVM 1 JVM 2
HTTP
Get dependencies
Checks if artifact exists in local repository.
Download artifact
Save artifact in local repository
Soaring Eagle L.L.C
Maven 1.0 Repository
Soaring Eagle L.L.C
Maven 2.0 Repository
Soaring Eagle L.L.C
Agenda
• Why Maven?• Maven 101• Deployments with Maven• Maven integrations• Maven in the enterprise• Maven 1.0 versus 2.0• Demo
Soaring Eagle L.L.C
Deployments with Maven
• It’s still an unconsolidated area in (1.0)• Several plug-ins can be used
o Artifacto SCMo Releaseo Disto Siteo Artifact generation pluginso Weblogic Plugin
• In the future, to be replaced by Maven-Wagon and Maven-SCM
Soaring Eagle L.L.C
Release Management
• Integrates with multiple Source code control systems.
• Integrates with JIRA for release management• Allows for separation of concerns to support SOX
initiatives.• Provides audit trail• Easy automation for no touch build and deployment
o Reduces possibility of errors
Soaring Eagle L.L.C
Agenda
• Why Maven?• Maven 101• Deployments with Maven• Maven integrations• Maven in the enterprise• Maven 1.0 versus 2.0• Demo
Soaring Eagle L.L.C
Maven integrations• IDE
o Mevenide (Eclipse + Net beans + JBuilder) Goal launcher Search in well known Maven remote repos POM editor POM validation POM/IDE synchronizer Jelly editor Maven builder nature (know which goals should be run when
resources change)• Continuous builds
o Cruise Control, Damage Control, Gump, Continuum• Future (m2): all Java
o Easier integrationo Talks about a Maven IDE
Soaring Eagle L.L.C
Agenda
• Why Maven?• Maven 101• Deployments with Maven• Maven integrations• Maven in the enterprise• Maven 1.0 versus 2.0• Demo
Soaring Eagle L.L.C
Continuous build
RemoteRepository
Maven Continuous
Build
LocalRepository Synchronization
A B
C
Project C Build
get dependent artifacts from A and B
Soaring Eagle L.L.C
Multi-location Set-up
Src Repository(CVS)
Continuous Build
MavenRemote
Repository
MavenRemote
Repository
Internet connection / leased line
commits
commits
Synchronization (rsync)
Country 1Country 2
Soaring Eagle L.L.C
Maven repositories
Project ARemote
Repository
EnterpriseRemote
Repository
Snapshots
Stable versions
Project BRemote
RepositorySnapshots
Soaring Eagle L.L.C
Team organization
• Build Coacho The new type of Quality Manager?o Overall build responsibility
Schedule build improvements in project iterations Defines quality strategies
E.g. Clover: start at 0% and at each iteration increase to level attained. Fail build if below.o Manages build improvementso Improve build-awareness
Every day commit by team Run local build before commits
o Gather build requirements from teams What checkstyle rules do we want to apply? Is the build running fast enough?
o Analyze reasons for build failures• Build leaders in each team
o Analyze build failureso Ensure build failure are given top priority and get fixed ASAPo Coaches team to be build-aware and listen to team
Project Manager
Build Coach Team N
Build Leader
Soaring Eagle L.L.C
Agenda
• Why Maven?• Maven 101• Deployments with Maven• Maven integrations• Maven in the enterprise• Maven 1.0 versus 2.0• Demo
Soaring Eagle L.L.C
Maven 1.0 VS 2.0
• Maven 1.0o project.xml,
maven.xml, project.properties
o build.propertieso Open Lifecycleo Plug-ins in Jelly
Loose project dependencies
Soaring Eagle L.L.C
Maven 1.0 VS 2.0 (Cont)
• Maven 2.0o Defined Inter-Project
Dependencieso Defined project typeso High performanceo Plug-ins in Marmalade,
Ant or Java
• pom.xml• settings.xml• Defined Lifecycle• Lifecycle based plug-in
goals• Finer grained project
configuration
Soaring Eagle L.L.C
Agenda
• Why Maven?• Maven 101• Deployments with Maven• Maven integrations• Maven in the enterprise• Maven 1.0 versus 2.0• Demo
Soaring Eagle L.L.C
Demo time
• Create a new project using the archetype plugin• Create a matching Eclipse project using the eclipse
plugin• Create a jar and run the unit tests (jar/test plug-ins)• Create the developer’s website including reports• Prepare a release• Produce a Release• Continuum