practical maven-slides 2

16
Practical Maven Will Iverson cascadetg.com/maven

Upload: will-iverson

Post on 03-Sep-2014

3.911 views

Category:

Technology


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Practical maven-slides 2

Practical MavenWill Iverson

cascadetg.com/maven

Page 2: Practical maven-slides 2

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

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

Why Maven?

JARTests

Integration Tests Deployment

Documentation

Web Site

Dependencies

Conditional Builds

WAR

ResourcesContinuous Integration

Reporting

Page 5: Practical maven-slides 2

Maven “versus” Ant?

Maven Create Artifacts

(e.g. JARs, WARs, EARs, etc...)

AntGeneral Purpose Tooling

Page 6: Practical maven-slides 2

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

Back to Basics

• Let’s create a JAR

• Let’s create a WAR

• Let’s link the two!

Page 8: Practical maven-slides 2

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

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

Dependencies

• Group

• Artifact

• Version

• Scope

• Tip: Declare Plugin Dependencies in the Plugin!

Page 11: Practical maven-slides 2

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

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

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

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

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

Q & A