Practical Maven
       Will Iverson

   cascadetg.com/maven
Agenda
•   Define                  •   Deployment

    •   Why?               •   Tool Commentary

    •   Maven v. Ant    ...
Maven Defined

• Maven is a software project management
  and comprehension tool.

• Based on the concept of a project obje...
Why Maven?
     Web Site            Reporting

Documentation            Dependencies

  Tests            JAR         WAR

...
Maven “versus” Ant?
        Maven
  Create Artifacts
(e.g. JARs, WARs, EARs, etc...)




                                 ...
Maven = Convention
 over Configuration
• Directories
 • Source, Tests, Resources
• Goals
 • Clean, Test, Install, Package, ...
Back to Basics

• Let’s create a JAR
• Let’s create a WAR
• Let’s link the two!
Goals and Plugins

   Goal = One Word Target
     e.g. clean, test, compile, deploy


 Plugin = Two Word Action
e.g. compi...
Ok...

• Built-in super pom.xml (in Maven install)
• Local settings.xml
• Project pom.xml (with packaging)
• Type a goal, ...
Dependencies

• Group
• Artifact
• Version
• Scope
•   Tip: Declare Plugin Dependencies in the Plugin!
Repositories
• Local                           Internet
 • ~/.m2/repository               (ibiblio)

• Remote             ...
Reporting
•   Built-In                •   Static Code Analysis
    •  Test Results             •  PMD
•   Plugins         ...
Deployment
  • Single Command To Deploy
   • Pushes artifact to server
  • (Almost) Single Command To Release
   • Houseke...
Tool Commentary
•   NetBeans 6.7

•   Eclipse (via Plugin)

•   Artifactory, Nexus
                              Defacto S...
All Star Directories
          Example
•   Most complex project (business-logic)
•   Conditional builds (data-migration, i...
Q &A
Upcoming SlideShare
Loading in...5
×

Practical maven-slides 2

3,671

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,671
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
84
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "Practical maven-slides 2"

  1. 1. Practical Maven Will Iverson cascadetg.com/maven
  2. 2. Agenda • Define • Deployment • Why? • Tool Commentary • Maven v. Ant • Q &A • Basics • Dependencies Oh yeah, demos & examples, too... • Repositories
  3. 3. Maven Defined • Maven is a software project management and comprehension tool. • Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.
  4. 4. Why Maven? Web Site Reporting Documentation Dependencies Tests JAR WAR Continuous Integration Resources Integration Tests Deployment Conditional Builds
  5. 5. Maven “versus” Ant? Maven Create Artifacts (e.g. JARs, WARs, EARs, etc...) Ant General Purpose Tooling
  6. 6. Maven = Convention over Configuration • Directories • Source, Tests, Resources • Goals • Clean, Test, Install, Package, Deploy, Site... • But... you have to learn the conventions! • Maven’s learning curve in a nutshell
  7. 7. Back to Basics • Let’s create a JAR • Let’s create a WAR • Let’s link the two!
  8. 8. Goals and Plugins Goal = One Word Target e.g. clean, test, compile, deploy Plugin = Two Word Action e.g. compile:compile, jar:test-jar, jetty:run
  9. 9. Ok... • Built-in super pom.xml (in Maven install) • Local settings.xml • Project pom.xml (with packaging) • Type a goal, and the lifecycle runs the bound plugins
  10. 10. Dependencies • Group • Artifact • Version • Scope • Tip: Declare Plugin Dependencies in the Plugin!
  11. 11. Repositories • Local Internet • ~/.m2/repository (ibiblio) • Remote Artifactory • Servers that hold released binaries Local (file system) • e.g. Artifactory, Nexus
  12. 12. Reporting • Built-In • Static Code Analysis • Test Results • PMD • Plugins • CheckStyle • Test Coverage • FindBugs (Cobertura) • //TODO • Javadoc with auto- generated UML • Schema documentation (SchemaSpy)
  13. 13. Deployment • Single Command To Deploy • Pushes artifact to server • (Almost) Single Command To Release • Housekeeping + deployment mvn --batch-mode release:prepare release:perform
  14. 14. Tool Commentary • NetBeans 6.7 • Eclipse (via Plugin) • Artifactory, Nexus Defacto Standard? • Hudson • Repository Format • e.g. SVN HTTP trick
  15. 15. All Star Directories Example • Most complex project (business-logic) • Conditional builds (data-migration, integration tests) • ~20 compile, ~15 test dependencies = apx 75 resolved dependencies • Automatic releases via Hudson, including JAR, Test JAR, attached sources, MD5 hashes • Build stamps SVN version # in manifest • Database wipe and reset, including DbUnit Fixture generation as part of clean - with data extracted from a dependency JAR • Site documentation (auto-gen) includes Cobertura code coverage, CheckStyle, PMD, FindBugs, full schema info for ~160 tables (including diagrams), Javadoc (with autogen UML class diagrams) • How many lines of XML? 786 lines (including comments)
  16. 16. Q &A
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×