Practical maven-slides 2
-
Upload
will-iverson -
Category
Technology
-
view
3.911 -
download
2
description
Transcript of Practical maven-slides 2
![Page 1: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/1.jpg)
Practical MavenWill Iverson
cascadetg.com/maven
![Page 2: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/2.jpg)
Agenda
• Define
• Why?
• Maven v. Ant
• Basics
• Dependencies
• Repositories
• Deployment
• Tool Commentary
• Q & A
Oh yeah, demos & examples, too...
![Page 3: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/3.jpg)
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.
![Page 4: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/4.jpg)
Why Maven?
JARTests
Integration Tests Deployment
Documentation
Web Site
Dependencies
Conditional Builds
WAR
ResourcesContinuous Integration
Reporting
![Page 5: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/5.jpg)
Maven “versus” Ant?
Maven Create Artifacts
(e.g. JARs, WARs, EARs, etc...)
AntGeneral Purpose Tooling
![Page 6: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/6.jpg)
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
![Page 7: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/7.jpg)
Back to Basics
• Let’s create a JAR
• Let’s create a WAR
• Let’s link the two!
![Page 8: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/8.jpg)
Goals and Plugins
Goal = One Word Targete.g. clean, test, compile, deploy
Plugin = Two Word Actione.g. compile:compile, jar:test-jar, jetty:run
![Page 9: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/9.jpg)
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
![Page 10: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/10.jpg)
Dependencies
• Group
• Artifact
• Version
• Scope
• Tip: Declare Plugin Dependencies in the Plugin!
![Page 11: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/11.jpg)
Repositories
• Local
• ~/.m2/repository
• Remote
• Servers that hold released binaries
• e.g. Artifactory, Nexus
Internet(ibiblio)
Artifactory
Local(file system)
![Page 12: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/12.jpg)
Reporting
• Built-In
• Test Results
• Plugins
• Test Coverage (Cobertura)
• Javadoc with auto-generated UML
• Schema documentation (SchemaSpy)
• Static Code Analysis
• PMD
• CheckStyle
• FindBugs
• //TODO
![Page 13: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/13.jpg)
Deployment
• Single Command To Deploy
• Pushes artifact to server
• (Almost) Single Command To Release
• Housekeeping + deployment
mvn --batch-mode release:prepare release:perform
![Page 14: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/14.jpg)
Tool Commentary
• NetBeans 6.7
• Eclipse (via Plugin)
• Artifactory, Nexus
• Hudson
• Repository Format
• e.g. SVN HTTP trick
Defacto Standard?
![Page 15: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/15.jpg)
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)
![Page 16: Practical maven-slides 2](https://reader036.fdocuments.us/reader036/viewer/2022081820/5407acd08d7f7288088b4e32/html5/thumbnails/16.jpg)
Q & A