Handwritten Text Recognition for manuscripts and early printed texts
The Maven2 Revolution Project Development Approach
1. The Maven2 Revolution
A new approach to project
development
Dror Bereznitsky
AlphaCSP
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar
2. Agenda
• What is Maven?
• Core Concepts of Maven 2
– Project Object Model
– The Build Lifecycle
– Maven Plugins
– The dependency Mechanism
– Repositories
• Maven vs. Ant
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 2
3. What is Maven ?
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar
4. A Build Survey
How much time do you spend creating and
managing your build files?
How many times have you created a new
build script from scratch?
Can someone new to your project can
immediately build, test, deploy it without
looking at documentation?
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 4
5. A Build Survey
If you answered :
1. Too much time
2. More than I can remember
3. No way
you are probably not working with
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 5
6. What is Maven?
A new approach to project development
• Configure your build don’t script it
• Define what to build not how
• Reuse of build logic
• Coherent Organization of Dependencies
A development tool – not building blocks
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 6
7. Maven’s Primary Goal
What is Maven’s project goal ?
Maven's primary goal is
to allow a developer to
understand the complete
state of a project
in the shortest period of time
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 7
8. The Primary Goal ..
The way to achieve this goal is:
• Making the build process easy
• Providing a uniform build system
• Providing guidelines for
best practices development
• Providing quality project information
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 8
9. Main Features
• Superior dependency management
• A large repository of libraries and metadata
• Multiple projects handling
• Extensible, easy to write plugins
• Coherent site of project information
• Release management and distribution
publication
• Multiple language support – C++, Java …
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 9
10. Core Concepts of Maven 2
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar
11. Project Object Model
Define What, not How
• All the information required for the build is
contained in a single POM,
“Project Object Model”, XML file
• The developer provides information about
what is being built and not how
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 11
12. Project Object Model ..
The POM contains detailed METADATA
information about the project:
– Versioning and configuration management
– Dependencies
– Project structure
– Application and testing resources
And much more …
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 12
13. A POM Example
All the information required for the build in a single file
1 <project>
2 <modelVersion>4.0.0</modelVersion>
3 <groupId>com.alphacsp</groupId>
4 <artifactId>my-app</artifactId>
5 <packaging>jar</packaging>
6 <version>1.0-SNAPSHOT</version>
7 <dependencies>
8 <dependency>
9 <groupId>junit</groupId>
10 <artifactId>junit</artifactId>
11 <version>3.8.1</version>
12 <scope>test</scope>
13 </dependency>
14 </dependencies>
15 </project>
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 13
14. The Super POM
How this is possible using a 15 line file?
• Maven's implicitly use its Super POM
• Super POM carries with it all the default
conventions that Maven encourages
• Super POM is the parent of all POMs
• Analog of the Java language's
java.lang.Object class.
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 14
15. The Super POM ..
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 15
16. Standard Directory Layout
• A common directory
layout –
immediately feel at home
in any Maven project
• Based on best practices
• Simplifies the POM
• Can be created using
Archetypes
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 16
17. The Build Lifecycle
• Software projects generally follow similar
build paths: preparation, compilation,
testing, packaging, installation, etc.
• Maven2 is based around the central concept
of a build lifecycle – the process for
building and distributing a particular artifact
is clearly defined
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 17
18. Phases and Goals
The build life cycle consists of a series of phases
where each phase can perform one or more
actions, or goals
compile test
deploy package
install
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 18
19. The Build Lifecycle
The lifecycle phase invokes the plugins it needs to
complete its task and other dependant lifecycles
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 19
20. The 80/20 Rule
• Using the default lifecycle mapping, Maven
can build a basic project with little or no
modification – 80% case
• in certain circumstances, a project requires
special tasks in order to build successfully
• Maven can integrate these custom tasks
into the build process through its
extensible plugin framework.
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 20
21. Maven Plugins
Maven is actually a platform that executes
plugins within a build life cycle in order to
perform the build tasks
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 21
22. Maven Plugins ..
• With most projects, the plugins provided
“out of the box” by Maven are enough.
• More plugins can be found at the Apache
Maven Project and CodeHaus Mojo project.
• If needed, you can write custom plugins to
perform special build tasks.
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 22
23. Maven Mojo
“mojo” – maven old java object
• Plug-in developers only need to make
their individual goal, “mojo”, perform a
single task.
• A “mojo” has a set of inputs and
outputs.
• Plug-ins consist of one or more “mojos”
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 23
25. Maven-Anno-Mojo
Let you use java 5.0 annotations syntax
instead of doclets for writing your mojos
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 25
26. Maven-Anno-Mojo ..
• Inheritance between plugins
• All the benefits of Java 5.0 – generics,
autoboxing …
• Delegation of execution to POJOs
• Natural Ant java tasks integration – not XML
based
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 26
27. The Dependency Mechanism
Maven excels in dependency management
• Transitive dependencies
• Dependency Scope
• Dependency Management
• Dependency exclusion
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 27
28. The Dependency Mechanism ..
Just Define your dependencies and forget about
them - maven will do the rest for you:
• Download the dependency
• Resolve all transient dependencies
• Add dependencies to compilation and test
classpath/include path
• Bundle dependencies when needed
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 28
29. The Dependency Mechanism …
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 29
30. Maven 2 Repositories
Maven repositories
shares the same
hierarchical structure
that hold the build
artifacts –
• Group
• Artifact
• Version
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 30
31. Maven 2 Repositories ..
There are two types of repositories:
• Remote - any type of repository, accessed by a
variety of protocols (file://, http://...).
http://repo1.maven.org is the central repository
• Local - a local cache of the
remote downloads and the latest build artifacts
Usually at : ${user.home}/.m2/repository
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 31
34. Site Generation
Maven is famous for its
Site generation that
includes:
a reference to the build
server
Javadoc
source XRef
issue tracking reference
test and quality reports
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 34
35. Site examples – code coverage
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 35
36. Site examples – Surefire report
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 36
37. Site – Custom Look & Feel
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 37
38. IDE Support
Maven has some neat plug-ins for IDE project
generation, including:
– IntelliJ IDEA
– Eclipse
– Netbeans
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 38
39. IDE Support ..
• The IDE projects created include:
– All the dependencies 3rd party/internal
– Dependency source linking
• The created project is ready to compile, test
, debug and run.
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 39
40. Multiple Language Support
• Maven supports
multiple development
languages such as
Java , C++, C, C#,
Fortran and more.
• Different languages
has their own
common standard
layout.
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 40
42. Maven vs. Ant
OK, but Ant is working fine !
•Ant provides building blocks for a toolset - Maven
provides a working tool
•Ant has no build lifecycle, repositories, standard
project layout, dependency management …
you have to do it by yourself !
•Ant scripts become complex
•Ant scripts are not reusable – promotes duplication
•Ant is becoming legacy and not moving fast ahead
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 42
43. MyApp – Ant Build File – 141 lines
141 Lines of code !!!
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 43
44. MyApp - Maven Build File – 17 lines
17 Lines of code
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 44
45. Maven vs. Ant ..
From our experience in Ant migration
projects there is a 1:30 ratio in
the number of lines of code
between Maven2 and Ant.
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 45
46. Your Turn Now
Q&A
Copyright AlphaCSP Israel 2006 - The Ultimate Development Environment Seminar Page 46