practical maven-slides 2

Post on 03-Sep-2014

3.911 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

Practical MavenWill Iverson

cascadetg.com/maven

Agenda

• Define

• Why?

• Maven v. Ant

• Basics

• Dependencies

• Repositories

• Deployment

• Tool Commentary

• Q & A

Oh yeah, demos & examples, too...

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.

Why Maven?

JARTests

Integration Tests Deployment

Documentation

Web Site

Dependencies

Conditional Builds

WAR

ResourcesContinuous Integration

Reporting

Maven “versus” Ant?

Maven Create Artifacts

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

AntGeneral Purpose Tooling

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

Back to Basics

• Let’s create a JAR

• Let’s create a WAR

• Let’s link the two!

Goals and Plugins

Goal = One Word Targete.g. clean, test, compile, deploy

Plugin = Two Word Actione.g. compile:compile, jar:test-jar, jetty:run

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

Dependencies

• Group

• Artifact

• Version

• Scope

• Tip: Declare Plugin Dependencies in the Plugin!

Repositories

• Local

• ~/.m2/repository

• Remote

• Servers that hold released binaries

• e.g. Artifactory, Nexus

Internet(ibiblio)

Artifactory

Local(file system)

Reporting

• Built-In

• Test Results

• Plugins

• Test Coverage (Cobertura)

• Javadoc with auto-generated UML

• Schema documentation (SchemaSpy)

• Static Code Analysis

• PMD

• CheckStyle

• FindBugs

• //TODO

Deployment

• Single Command To Deploy

• Pushes artifact to server

• (Almost) Single Command To Release

• Housekeeping + deployment

mvn --batch-mode release:prepare release:perform

Tool Commentary

• NetBeans 6.7

• Eclipse (via Plugin)

• Artifactory, Nexus

• Hudson

• Repository Format

• e.g. SVN HTTP trick

Defacto Standard?

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)

Q & A

top related