Maven 1.0 - PowerPoint PPT Presentation

About This Presentation
Title:

Maven 1.0

Description:

Maven is a build container ' Pivolis 2004. Advantages of a ... One main artifact per build. Whenever there's a need to share artifacts between projects ... – PowerPoint PPT presentation

Number of Views:286
Avg rating:3.0/5.0
Slides: 43
Provided by: vma83
Category:
Tags: build | maven

less

Transcript and Presenter's Notes

Title: Maven 1.0


1
Maven 1.0
  • Vincent Massol16/12/04

2
Agenda
  • Why Maven?
  • Maven 101
  • Setting up a multiproject
  • Deployments with Maven
  • Maven integrations
  • Maven in the enterprise
  • Writing a plugin
  • Mavens future

3
Agenda
  • Why Maven?
  • Maven 101
  • Setting up a multiproject
  • Deployments with Maven
  • Maven integrations
  • Maven in the enterprise
  • Writing a plugin
  • Mavens future

4
Analogy How to develop an application?
Solution 1
Solution 2
My Application
My Application
Services
Container
API
E.g. Application Server, Eclipse RCP, Netbeans,
etc
Frameworks
5
How to develop a build?
Solution 1 Ant
Solution 2 Maven
My Build
My Build
Goals/Plugins
Maven (Container)
Task calls
Ant tasks
 Maven is a build container 
6
Advantages of a Container approach
  • Ability to reuse existing services
  • More than 100 existing Maven plugins (jar,
    cactus, clover, jira, site, dashboard, etc)
  • Easy to start with
  • All working, just need to configure and extend
  • Ability to benefit from new services simply by
    upgrading
  • Well-defined and shared structure/architecture
  • Easier to maintain
  • Knowledgable resources on the market
  • Well-defined structure
  • It makes sense to use a custom approach when
    flexibility is a must
  • This is not usually the case for builds

7
Agenda
  • Why Maven?
  • Maven 101
  • Setting up a multiproject
  • Deployments with Maven
  • Maven integrations
  • Maven in the enterprise
  • Writing a plugin
  • Mavens future

8
Maven 101
  • Maven in 3 concepts
  • POM (Project Object Model)
  • Plugins
  • Made of Goals Actions
  • Repositories
  • Maven files
  • project.xml
  • POM
  • maven.xml
  • Custom goals in Jelly
  • Goal, preGoal, postGoal
  • project.properties
  • Configuration
  • build.properties
  • Configuration

9
POM example (1/2)
10
POM example (2/2)
11
Project lifecycle with Maven plugins (1/2)
1
2
3
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- J
Coverage - JDepend - Ncss - Patterntesting -
Clirr
12
Project lifecycle with Maven plugins (2/2)
4
5
6
EnvironmentDeployment Functional tests
Site/Report Generation
Deployment
- JBoss- WebSphere- WebLogic- Jetty
- Cactus
- Latka - HttpUnit - Abbot - (Cargo)
- Site Changes Jira Dashboard Changelog
File activity- Developer activity
StatCvs
Announcement
- Site - Dist - Artifact- War/Ejb/Ear/Jar... -
Scm
- Nsis - (Cargo)
13
Demo time
  • Create a new project using the genapp plugin
  • 10 seconds
  • Create a matching Eclipse project using the
    eclipse plugin
  • 5 seconds
  • Create a jar and run the unit tests (jar/test
    plugins)
  • 5 seconds
  • Create the developers website including reports
  • 15 seconds

14
Maven Repositories
Web Server
project.xml (POM)
Download artifact
Get dependencies
1
Remote Repository
3
Maven core
HTTP
Local Repository
2
4
Save artifact in local repository
Checks if artifact exists in local repo.
JVM 1
JVM 2
15
Agenda
  • Why Maven?
  • Maven 101
  • Setting up a multiproject
  • Deployments with Maven
  • Maven integrations
  • Maven in the enterprise
  • Writing a plugin
  • Mavens future

16
Multiproject example Cargo
  • cargocommoncoreantdistributionsamples
    java ant testdata simple-ear


core
ant
distribution
samples/java
testdata/
samples/ant
17
Multiproject best practices (1/3)
  • Use a common directory to share build-related
    resources
  • Shared Maven POM
  • project.xml
  • Shared custom Maven goals
  • maven.xml
  • Shared Maven properties
  • project.properties
  • Checkstyle files
  • Licenses
  • etc

18
Multiproject best practices (2/3)
  • Create custom project-wide goals
  • cargodist
  • cargoclean

cargosite cargodeploy
cargoclover cargosite-deploy
etc
19
Multiproject best practices (3/3)
  • Create lots of Maven projects
  • Same as with OOP, separation of concerns is good
  • With Maven it is separation of builds
  • One main artifact per build
  • Whenever theres a need to share artifacts
    between projects
  • Ex testdata/ for Cargo
  • Maven needs to improve handling of in-situ
    artifacts (m2)
  • Currently needs to go through local Maven
    repository

20
Typical J2EE multiproject organisation
applications a set of modules packaged together
to make an application. It contains configuration
files
output EAR, JNLP WAR, etc
containers a set of applications that execute
inside a container (ex JBoss, Web server, Tibco,
Database, etc). It contains container
configuration files and container directory
structure. output configured container as a
zip.
modules set of libraries containing business
logic. They can depend on each other.

output jars, ejb-jars, wars, rars, etc
nodes a set of containers that will be deployed
on a specific type of machine.

output configured node as a zip.
system represents the full system, i.e. a set of
nodes. output set of nodes packaged in a zip
for example.
21
Agenda
  • Why Maven?
  • Maven 101
  • Setting up a multiproject
  • Deployments with Maven
  • Maven integrations
  • Maven in the enterprise
  • Writing a plugin
  • Mavens future

22
Deployments with Maven
  • Its still an unconsolidated area
  • Several plugins can be used
  • Artifact
  • SCM
  • Release
  • Dist
  • Site
  • Artifact generation plugins
  • In the future, to be replaced by Maven-Wagon and
    Maven-SCM

23
Deploying an artifact
  • Several plugins have  install  and  deploy 
    goals
  •  install  installs the artifact in the local
    repository
  •  deploy  deploys the artifact to a remote
    Repository
  • Ex jardeploy, wardeploy, ejbdeploy,
    eardeploy, rardeploy
  • Use directly artifact plugin
  • "ejbjarwar"project"pom"/
  • Optionally use a typeHandler attribute to provide
    your own deployment (you must extend
    ArtifactTypeHandlerQQQ
  • Several methods supported
  • HTTP, File, FTP, SFTP, SCP (JSch), External
    (batch, shell), SCP (External scp command)
  • Defined by the URL provided in the
    maven.repo.reponame property
  • Configured using properties
  • maven.repo.listapache
  • maven.repo.apachescp//pom.distributionSite
  • maven.repo.apache.directorypom.distributionDire
    ctory
  • maven.repo.apache.groupmaven
  • maven.repo.apache.username
  • maven.repo.apache.privatekey
  • maven.repo.apache.passphrase

24
Deploying a site
  • The Maven site is deployed using the sitedeploy
    goal
  • It is still using the  old  way of deploying
  • Needs to be moved to the new Deployer
  • Configured using the maven.site.deploy.method
    property
  • Supports the following protocols
  • Fs, FTP, SCP/SSH (command line)
  • Example of configuration properties
  • maven.username
  • maven.password (FTP)
  • maven.ssh.executable (SCP/SSH)
  • maven.scp.executable (SCP/SSH)
  • POM siteDirectory
  • POM siteAddress

25
Other plugins used for deployment
  • Dist plugin binary an src distributions (tar.gz
    and zip)
  • Uses Artifact plugin under the hood for deploying
    the distribution
  • Scm plugin
  • Currently only supports CVS
  • Assume usage of tags in project.xml
  • Assume usage of changes.xml file
  • Does not work if youre using the JIRA strategy
    for example
  • Future use Maven-SCM
  • Release plugin deprecated, do not use.
  • The idea was to perform additional task on
    release notify blogs, lists, increase version,
    etc what scm plugin is currently doing
  • Nsis plugin Used to generate Win32 installers

26
Agenda
  • Why Maven?
  • Maven 101
  • Setting up a multiproject
  • Deployments with Maven
  • Maven integrations
  • Maven in the enterprise
  • Writing a plugin
  • Mavens future

27
Maven integrations
  • IDE
  • Mevenide (Eclipse Netbeans 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
  • CruiseControl, DamageControl, Gump, Continuum
  • Future (m2) all Java
  • Easier integration
  • Talks about a Maven IDE

28
Agenda
  • Why Maven?
  • Maven 101
  • Setting up a multiproject
  • Deployments with Maven
  • Maven integrations
  • Maven in the enterprise
  • Maven and continuous builds
  • Writing a plugin
  • Mavens future

29
Continuous build using SNAPSHOTs
Remote Repository
Local Repository
A
B
Synchronization
C
Deploy SNAPSHOTs
get dependent artifacts from A and B
Maven Continuous Build
Project C Build
30
Multi-location setup
Src Repository (CVS)
Internet connection / leased line
commits
commits
Continuous Build
Maven Remote Repository
Maven Remote Repository
Synchronization (rsync)
Country 1
Country 2
31
Maven repositories
Enterprise Remote Repository
Stable versions
Project A Remote Repository
Project B Remote Repository
SNAPSHOTs
SNAPSHOTs
32
Team organization
Project Manager
Build Coach
Team N
  • Build Coach
  • The new type of Quality Manager?
  • 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.
  • Manages build improvements
  • Improve build-awareness
  • Every day commit by team
  • Run local build before commits
  • Gather build requirements from teams
  • What checkstyle rules do we want to apply?
  • Is the build running fast enough?
  • Analyze reasons for build failures
  • Build leaders in each team
  • Analyze build failures
  • Ensure build failure are given top priority and
    get fixed ASAP
  • Coaches team to be build-aware and listen to
    team

Build Leader
33
Agenda
  • Why Maven?
  • Maven 101
  • Setting up a multiproject
  • Deployments with Maven
  • Maven integrations
  • Maven in the enterprise
  • Writing a plugin
  • Mavens future

34
Writing a Maven plugin
plugin.jelly
lycore" xmlnsant"jellyant" e"hello" description"Send nice message"
Hello world!

To build and deploy maven plugininstall
35
Writing tests for a Maven plugin
maven.xml
util" xmlnsj"jellycore" xmlnsant"jelly
ant" xmlnsx"jellyxml" xmlnsassert"asse
rt" ...

To start the tests maven plugintest
36
Tips and tricks to write a Maven plugin
  • Check out the  maven-plugins  CVS module. There
    are over 80 plugins implemented there
  • Refer to the Jelly Tag documentation
  • http//jakarta.apache.org/commons/jelly
  • Watch out for dots (.) in Jelly variable names
  • Because a dot indicates a method call. Jelly uses
    JEXL which calls Java expression
  • Incorrect
  • Correct
  • riable)
  • Really, learn to read Jelly from other plugin
    code!

37
Agenda
  • Why Maven?
  • Maven 101
  • Setting up a multiproject
  • Deployments with Maven
  • Maven integrations
  • Maven in the enterprise
  • Writing a plugin
  • Mavens future

38
Maven 2
  • Better architecture based on Plexus (lightweight
    container)
  • Remove dependency on Jelly. Primary language for
    plugin development is Java but other languages
    can be plugged in (Jelly, Marmalade, BeanShell,
    etc)
  • Faster!
  • Embeddable, IDE-friendly
  • Fix most limitations of Maven 1
  • Rewrite from scratch
  • But reuse Maven 1 use cases
  • Hopefully ability to reuse Maven 1 plugins
  • Not ready yet! First version probably not
    available before mid-2005.
  • Before that Maven 1.1, possibly with some m2
    components
  • Use Maven Model tighten POM definition, upgrade
  • Use Maven Wagon artifact handler
  • Use Maven SCM unified Java API for SCMs

39
Some limitations of Maven 1.x
  • Handling of local artifacts (aka in-situ
    artifacts)
  • Better versioning requirements for dependencies
    (e.g. 1.3)
  • Share common dependencies in POM between
    projects
  • No dependency types (runtime, test, etc)
  • Transitive dependencies support
  • Transparent plugin download
  • Unified configuration (project.xml vs properties
    file)
  • Plugin configuration in XML (Plugin descriptor)

40
Resources
  • Web sites
  • Maven
  • http//maven.apache.org/
  • Maven Wiki
  • http//wiki.codehaus.org/maven/
  • Jelly
  • http//jakarta.apache.org/commons/jelly
  • Maven blogs
  • http//www.mavenblogs.com/
  • Presentations
  • J2EE with Maven
  • http//www.pivolis.com/pdf/J2EE_projects_Maven_V1.
    1.pdf
  • Enterprise builds
  • http//www.pivolis.com/pdf/Enterprise_Builds_V1.0.
    pdf

41
QA
?
42
Tips and tricks
  • Do not try to migrate complex builds to Maven
  • Its frustrating
  • Its difficult to adapt from a custom structure
    to the structure recommended by Maven
  • Trust Maven!
  • Let it guide your build structure
  • Itll make your life easier and youll be able to
    use all existing plugins all the more easily
Write a Comment
User Comments (0)
About PowerShow.com