105
Maven 3.0 What’s new in by Matthew McCullough, Ambient Ideas, LLC Wednesday, June 2, 2010

s new in Maven 3 - Jazoon

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: s new in Maven 3 - Jazoon

Maven 3.0What’s new in

by Matthew McCullough, Ambient Ideas, LLC

Wednesday, June 2, 2010

Page 2: s new in Maven 3 - Jazoon

In the beginner’s mind there aremany possibilities.

In the expert’s mind there are few.

Wednesday, June 2, 2010

Page 3: s new in Maven 3 - Jazoon

This Talk

Wednesday, June 2, 2010

Page 4: s new in Maven 3 - Jazoon

Maven and You

!Who will enjoy this talk?!Current Maven user!Familiar with POM syntax!Interested in preparing for Maven 3.0!Comfortable with betas

Wednesday, June 2, 2010

Page 5: s new in Maven 3 - Jazoon

TheRoadmap

Wednesday, June 2, 2010

Page 6: s new in Maven 3 - Jazoon

Wednesday, June 2, 2010

Page 7: s new in Maven 3 - Jazoon

3.0

Wednesday, June 2, 2010

Page 8: s new in Maven 3 - Jazoon

Compatibility!Tested against 100s of Maven 2 projects!Legacy simulation layers!Using for 6 months almost exclusively

!450+ integration tests

Wednesday, June 2, 2010

Page 9: s new in Maven 3 - Jazoon

Wednesday, June 2, 2010

Page 10: s new in Maven 3 - Jazoon

Wednesday, June 2, 2010

Page 11: s new in Maven 3 - Jazoon

Wednesday, June 2, 2010

Page 12: s new in Maven 3 - Jazoon

603!

Wednesday, June 2, 2010

Page 13: s new in Maven 3 - Jazoon

Speed!Performance tuned!Benchmarks

! Disk I/O! Network I/O! CPU! Memory

Wednesday, June 2, 2010

Page 14: s new in Maven 3 - Jazoon

Maven Speed Test

Wednesday, June 2, 2010

Page 15: s new in Maven 3 - Jazoon

Wednesday, June 2, 2010

Page 16: s new in Maven 3 - Jazoon

Quick! Faster execution! 10% faster in the demo

! Multi-threaded downloads! Parallel plugin execution! Java 5 optimized builds

Wednesday, June 2, 2010

Page 17: s new in Maven 3 - Jazoon

Wednesday, June 2, 2010

Page 18: s new in Maven 3 - Jazoon

Efficient! Memory conservative! 73% less in the demo

! Tuned data structures

Wednesday, June 2, 2010

Page 19: s new in Maven 3 - Jazoon

!Largely re-written for quality, flexibility!30% smaller code base!Continuous integration running test suite

Code

Wednesday, June 2, 2010

Page 20: s new in Maven 3 - Jazoon

Extensibility!Layers of abstraction!Plugin classloader partitioning!Plexus to Guice IOC rewrite!Fully embeddable

!Basis for derived tools

Wednesday, June 2, 2010

Page 21: s new in Maven 3 - Jazoon

How can you keep up with Maven 3?

Wednesday, June 2, 2010

Page 22: s new in Maven 3 - Jazoon

http://maven.apache.org/release-notes-3.0.x.html

Wednesday, June 2, 2010

Page 23: s new in Maven 3 - Jazoon

http://delicious.com/matthew.mccullough/maven

Wednesday, June 2, 2010

Page 24: s new in Maven 3 - Jazoon

POMs & Maven 3.0

Wednesday, June 2, 2010

Page 25: s new in Maven 3 - Jazoon

POM XML Syntax

! No POM syntax changes for Maven 3.0

<project> <modelVersion>4.0.0</modelVersion> <groupId>com.ambientideas</groupId> <artifactId>sample-barestbones</artifactId> <version>1.0-SNAPSHOT</version></project>

Wednesday, June 2, 2010

Page 26: s new in Maven 3 - Jazoon

POM XML Validations

! Heavily validated against common mistakes

! Forward-test with Maven 3.0!Switch back to 2.x for production

! 3.0 POMs run better on 2.x

Wednesday, June 2, 2010

Page 27: s new in Maven 3 - Jazoon

POM XML Validations

!Warns when plugin versions are not specified

Wednesday, June 2, 2010

Page 28: s new in Maven 3 - Jazoon

POM XML Validations

! Blocks duplicate dependencies!Examined in same POM only!Conflict resolution used otherwise

<dependency> <artifactId>junit</modelVersion> <groupId>junit</groupId> <version>3.8.1</version></dependency>...<dependency> <artifactId>junit</modelVersion> <groupId>junit</groupId> <version>3.8.2</version></dependency>

Wednesday, June 2, 2010

Page 29: s new in Maven 3 - Jazoon

“Duplicate dependency” error

Wednesday, June 2, 2010

Page 30: s new in Maven 3 - Jazoon

Help URLs

! Wiki page URLs now shown for all error messages

Wednesday, June 2, 2010

Page 31: s new in Maven 3 - Jazoon

Help URLs

! Wiki page URLs now shown for all error messages

Wednesday, June 2, 2010

Page 32: s new in Maven 3 - Jazoon

Wednesday, June 2, 2010

Page 33: s new in Maven 3 - Jazoon

Parent POM References

! Parent POMs now prefer to resolve from repositories!Better consistency on multi-module builds

! Version-less parent references will be allowed (not quite ready)

!Will require <relativePath> tag

Wednesday, June 2, 2010

Page 34: s new in Maven 3 - Jazoon

<project> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.ambientideas</groupId> <artifactId>sample-multimodulejava-parent</artifactId> <version>1.0-SNAPSHOT</version> </parent></project>

Wednesday, June 2, 2010

Page 35: s new in Maven 3 - Jazoon

<project> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.ambientideas</groupId> <artifactId>sample-multimodulejava-parent</artifactId> <version>1.0-SNAPSHOT</version> </parent></project>

Wednesday, June 2, 2010

Page 36: s new in Maven 3 - Jazoon

<project> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.ambientideas</groupId> <artifactId>sample-multimodulejava-parent</artifactId> <relativePath>../</relativePath> </parent></project>

Wednesday, June 2, 2010

Page 37: s new in Maven 3 - Jazoon

Profiles Consolidated

•Profiles.xml external file support removed

•Folded into pom.xml

•Already a best-practice

•Necessary for Polyglot Maven

Wednesday, June 2, 2010

Page 38: s new in Maven 3 - Jazoon

Artifact Behavior Changes

Wednesday, June 2, 2010

Page 39: s new in Maven 3 - Jazoon

Maven 1.0 Deprecated

• Maven 1.0 repository support removed<layout>legacy</layout>

Wednesday, June 2, 2010

Page 40: s new in Maven 3 - Jazoon

SNAPSHOT Datestamps

•Deprecated <uniqueVersion> false </uniqueVersion>

•SNAPSHOTs now always deployed with date-stamps

Wednesday, June 2, 2010

Page 41: s new in Maven 3 - Jazoon

Artifact Resolution Caching•Caches lookups whether found or missing

•Stored in:~/.m2/repo/.../<artifact>.lastUpdated

•Sample contents:#Last modified on: Thu Dec 31 10:42:13 MST 2009#Thu Dec 31 10:42:13 MST 2009http\://localhost\:8081/nexus/content/groups/public=12333938

•Overridden by:mvn <phase> -U

Wednesday, June 2, 2010

Page 42: s new in Maven 3 - Jazoon

Plugin Behavior Changes

Wednesday, June 2, 2010

Page 43: s new in Maven 3 - Jazoon

Core Changes: Plugins!Plugin version auto-selection favors RELEASEs over SNAPSHOTs

!Affects command-line invocation of plugins

Wednesday, June 2, 2010

Page 44: s new in Maven 3 - Jazoon

#Maven 2.x#Will run the newest SNAPSHOT, if one is cached locallymvn archetype:generate#...actually running

mvn org.apache.maven.plugins:maven-archetype-plugin:1.0-SNAPSHOT:generate

#Maven 3.x#Will always run the newest RELEASE in Maven 3.xmvn archetype:generate#...actually running

mvn org.apache.maven.plugins:maven-archetype-plugin:2.0:generate

Command Line

Wednesday, June 2, 2010

Page 45: s new in Maven 3 - Jazoon

Core Changes: Plugins!Plugins versions cannot be specified as RELEASE or LATEST

!Affects pom.xml configuration and command line fully-qualified invocation

Wednesday, June 2, 2010

Page 46: s new in Maven 3 - Jazoon

...<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-toolchains-plugin</artifactId> <version>LATEST</version></plugin>...

pom.xml

Wednesday, June 2, 2010

Page 47: s new in Maven 3 - Jazoon

...<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-toolchains-plugin</artifactId> <version>LATEST</version></plugin>...

pom.xml

Wednesday, June 2, 2010

Page 48: s new in Maven 3 - Jazoon

Core Changes: Plugins!Plugins only resolved from <pluginRepository> locations

Wednesday, June 2, 2010

Page 49: s new in Maven 3 - Jazoon

http://cwiki.apache.org/MAVEN/maven-3x-compatibility-notes.html

Wednesday, June 2, 2010

Page 50: s new in Maven 3 - Jazoon

toolchainWednesday, June 2, 2010

Page 51: s new in Maven 3 - Jazoon

What is toolchain?

!Single configuration for multiple plugins!Primarily supports JDK selection today!Extensible for other tools in the future

Wednesday, June 2, 2010

Page 52: s new in Maven 3 - Jazoon

Toolchain Config

!User tool definitions in file~/.m2/toolchains.xml

!Maven 3.0 command-line path specification!-t <toolchainspath>!--toolchains <toolchainspath>

Wednesday, June 2, 2010

Page 53: s new in Maven 3 - Jazoon

<?xml version="1.0" encoding="UTF8"?><toolchains> <toolchain> <type>jdk</type> <provides> <version>1.5</version> <vendor>apple</vendor> <id>default</id> </provides> <configuration> <jdkHome>/System/Library/Frameworks/JavaVM.framework/Versions/1.5</jdkHome> </configuration> </toolchain> <toolchain> <type>jdk</type> <provides> <version>1.6</version> <vendor>apple</vendor> <id>onesixjdk</id> </provides> <configuration> <jdkHome>/System/Library/Frameworks/JavaVM.framework/Versions/1.6</jdkHome> </configuration> </toolchain></toolchains>

toolchains.xml

Wednesday, June 2, 2010

Page 54: s new in Maven 3 - Jazoon

Using Toolchain

!Implemented as a Maven plugin!Add to <plugins> in pom.xml

!Plugin <configuration> specifies a toolchain to use!Toolchain specified by vendor and version

Wednesday, June 2, 2010

Page 55: s new in Maven 3 - Jazoon

...<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-toolchains-plugin</artifactId> <version>1.0</version> <executions> <execution> <phase>validate</phase> <goals> <goal>toolchain</goal> </goals> </execution> </executions> <configuration> <toolchains> <jdk> <version>1.5</version> <vendor>apple</vendor> </jdk> </toolchains> </configuration></plugin>...

pom.xml

Wednesday, June 2, 2010

Page 56: s new in Maven 3 - Jazoon

How does it work?

!Toolchain-enabled plugins read toolchain config first

!Plugins fall back to traditional per-plugin config if toolchain config not found

Wednesday, June 2, 2010

Page 57: s new in Maven 3 - Jazoon

Benefits

!Minimizes plugin configuration!Separates JDK selection from Maven core

Wednesday, June 2, 2010

Page 58: s new in Maven 3 - Jazoon

mvnshellWednesday, June 2, 2010

Page 59: s new in Maven 3 - Jazoon

http://shell.sonatype.org/

Wednesday, June 2, 2010

Page 60: s new in Maven 3 - Jazoon

Wednesday, June 2, 2010

Page 61: s new in Maven 3 - Jazoon

Wednesday, June 2, 2010

Page 62: s new in Maven 3 - Jazoon

What is mvnshell?

!High performance console!Maven 3.x add-on

Wednesday, June 2, 2010

Page 63: s new in Maven 3 - Jazoon

Wednesday, June 2, 2010

Page 64: s new in Maven 3 - Jazoon

Speed of Builds

Wednesday, June 2, 2010

Page 65: s new in Maven 3 - Jazoon

Performance of Shell

!220% faster in the demo!No JVM warm-up time!Strategies for caching

Wednesday, June 2, 2010

Page 66: s new in Maven 3 - Jazoon

Wednesday, June 2, 2010

Page 67: s new in Maven 3 - Jazoon

polyglotWednesday, June 2, 2010

Page 68: s new in Maven 3 - Jazoon

http://polyglot.sonatype.org/

Wednesday, June 2, 2010

Page 69: s new in Maven 3 - Jazoon

http://polyglot.sonatype.org/

Wednesday, June 2, 2010

Page 70: s new in Maven 3 - Jazoon

Wednesday, June 2, 2010

Page 71: s new in Maven 3 - Jazoon

What is polyglot Maven?

!Maven 3 superset!A full distribution of Maven!Enabled by Maven 3 embedding!Multi-language mvn command

Wednesday, June 2, 2010

Page 72: s new in Maven 3 - Jazoon

What is polyglot Maven?

!POM file converter!translate tool

!Any-to-Any language translation

Wednesday, June 2, 2010

Page 73: s new in Maven 3 - Jazoon

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.ambientideas</groupId> <artifactId>sample-dependency</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>Sample Project - One Dependency</name> <url>http://github.com/matthewmccullough/maven-training/</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies></project>

pom.xml

Wednesday, June 2, 2010

Page 74: s new in Maven 3 - Jazoon

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.ambientideas</groupId> <artifactId>sample-dependency</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>Sample Project - One Dependency</name> <url>http://github.com/matthewmccullough/maven-training/</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies></project>

pom.xml

Wednesday, June 2, 2010

Page 75: s new in Maven 3 - Jazoon

modelVersion: 4.0.0 artifactId: sample-dependencygroupId: com.ambientideasname: Sample Project - One Dependencypackaging: jarurl: http://github.com/matthewmccullough/maven-training/version: 1.0-SNAPSHOT

dependencies:- {artifactId: junit, groupId: junit, optional: false, scope: test, type: jar, version: 3.8.1}

pom.yaml

Wednesday, June 2, 2010

Page 76: s new in Maven 3 - Jazoon

(defproject main "com.ambientideas:sample-dependency:1.0-SNAPSHOT"

:model-version "4.0.0" :add-default-plugins false :name "Sample Project - One Dependency" :packaging "jar" :url "http://github.com/matthewmccullough/maven-training/" :test-dependencies [["junit:junit:3.8.1"]])

pom.clj

Wednesday, June 2, 2010

Page 77: s new in Maven 3 - Jazoon

project { m => m.artifactId = "sample-dependency" m.dependency { d => d.artifactId = "junit" d.groupId = "junit" d.optional = false d.scope = "test" d._type = "jar" d.version = "3.8.1" } m.groupId = "com.ambientideas" m.modelVersion = "4.0.0" m.name = "Sample Project - One Dependency" m.packaging = "jar" m.url = "http://github.com/matthewmccullough/maven-training/" m.version = "1.0-SNAPSHOT" }

pom.scala

Wednesday, June 2, 2010

Page 78: s new in Maven 3 - Jazoon

project { modelVersion '4.0.0' groupId 'com.ambientideas' artifactId 'sample-dependency' version '1.0-SNAPSHOT' name 'Sample Project - One Dependency' url 'http://github.com/matthewmccullough/maven-training/' dependencies { dependency { groupId 'junit' artifactId 'junit' version '3.8.1' scope 'test' } }}

pom.groovy

Wednesday, June 2, 2010

Page 79: s new in Maven 3 - Jazoon

Polyglot DSLs

!A true DSL framework!Maven lifecycle hooks

!Can modify execution plan!Supplement the lifecycle

Wednesday, June 2, 2010

Page 80: s new in Maven 3 - Jazoon

Polyglot Macros

!Maven-specific macros!Allows for more concise POMs!Groovy polyglot showcasing this

!No freeform scripting (yet)

Wednesday, June 2, 2010

Page 81: s new in Maven 3 - Jazoon

project { modelVersion '4.0.0' $artifact('com.ambientideas', 'sample-dependency’, '1.0-SNAPSHOT') name 'Sample Project - One Dependency' url 'http://github.com/matthewmccullough/maven-training/'

dependencies { dependency('junit', 'junit’, '3.8.1', ‘test') }}

pom.groovy with macros

Wednesday, June 2, 2010

Page 82: s new in Maven 3 - Jazoon

Where did we start from again?

Wednesday, June 2, 2010

Page 83: s new in Maven 3 - Jazoon

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.ambientideas</groupId> <artifactId>sample-dependency</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>Sample Project - One Dependency</name> <url>http://github.com/matthewmccullough/maven-training/</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies></project>

pom.xml

Wednesday, June 2, 2010

Page 84: s new in Maven 3 - Jazoon

M2EclipseWednesday, June 2, 2010

Page 85: s new in Maven 3 - Jazoon

Wednesday, June 2, 2010

Page 86: s new in Maven 3 - Jazoon

Upgrading M2Eclipse

!Latest version, 0.10!Code quality improvements!Performance increases!Packaging changes!Two distinct update sites!Core:! ! ! http://m2eclipse.sonatype.org/sites/m2e

!Extensions:! http://m2eclipse.sonatype.org/sites/m2e-extras

Wednesday, June 2, 2010

Page 87: s new in Maven 3 - Jazoon

Eclipse Versions Supported

!3.4!3.5!3.5.1 !(Recommended)

!3.6!! ! (Beta)

Wednesday, June 2, 2010

Page 88: s new in Maven 3 - Jazoon

Dependencies

! Visualizes conflicts! Graph and text form

! Dependency resolution tree! Answers “where is X being brought in from?”

Wednesday, June 2, 2010

Page 89: s new in Maven 3 - Jazoon

Dependencies

! Easy exclusions! Uses Eclipse refactoring engine

Wednesday, June 2, 2010

Page 90: s new in Maven 3 - Jazoon

Wednesday, June 2, 2010

Page 91: s new in Maven 3 - Jazoon

Class Search

! Search the entire central repository for! Artifact

! Package

! Classname

! Lucene database! Incremental updates

Wednesday, June 2, 2010

Page 92: s new in Maven 3 - Jazoon

Class Search

Wednesday, June 2, 2010

Page 93: s new in Maven 3 - Jazoon

Wednesday, June 2, 2010

Page 94: s new in Maven 3 - Jazoon

Maven 3.1Wednesday, June 2, 2010

Page 95: s new in Maven 3 - Jazoon

Maven 3.1 POM Changes

! Backwards compatibility by modelVersion! Final identifier TBD for 3.1 POM syntax! Allows 3.1 to read 3.0, 2.0 POMs

<project> <modelVersion>4.0.0</modelVersion> <groupId>com.ambientideas</groupId> <artifactId>sample-barestbones</artifactId> <version>1.0-SNAPSHOT</version></project>

Wednesday, June 2, 2010

Page 96: s new in Maven 3 - Jazoon

Maven 3.1 POM Changes

!pom.xml syntax changes!Site plugin takes over <reporting>

!“Mixins” for direct dependencies!Sometimes desired over POM inheritance

!Plugin security manager!settings.xml as default implementation

Wednesday, June 2, 2010

Page 97: s new in Maven 3 - Jazoon

SummaryWednesday, June 2, 2010

Page 98: s new in Maven 3 - Jazoon

Summary•Validations

•Performance

•Compatibility

•Toolchain

•Shell

•Polyglot

•M2Eclipse

Wednesday, June 2, 2010

Page 99: s new in Maven 3 - Jazoon

Maven 3.0What’s new in

EmailTwitterBlog

Matthew [email protected]@matthewmccullhttp://ambientideas.com/blog

Wednesday, June 2, 2010

Page 100: s new in Maven 3 - Jazoon

ReferencesWednesday, June 2, 2010

Page 101: s new in Maven 3 - Jazoon

!Maven 3 Core! Homepage

! http://maven.apache.org/

! Source Code! http://svn.apache.org/viewvc/maven/maven-3/trunk

! Wiki! http://cwiki.apache.org/MAVEN/maven-3x.html

! Bug Tracking! http://jira.codehaus.org/browse/MNG

! Compatibility! http://cwiki.apache.org/MAVEN/maven-3x-compatibility-notes.html

! Blog Posts! http://www.sonatype.com/people/2009/11/maven-3x-paving-the-desire-lines-

part-two/

! Bookmarks! http://delicious.com/matthewmccullough/maven

Wednesday, June 2, 2010

Page 102: s new in Maven 3 - Jazoon

!Maven 3 Site Plugin!Source Code! https://svn.apache.org/repos/asf/maven/plugins/branches/

maven-site-plugin-3.x/

!Wiki! http://cwiki.apache.org/MAVEN/maven-3x-and-site-plugin.html

Wednesday, June 2, 2010

Page 103: s new in Maven 3 - Jazoon

!Maven Shell!Source Code! http://github.com/sonatype/mvnsh/

!Wiki! https://docs.sonatype.org/display/MVNSH

!Homepage! http://shell.sonatype.org/

Wednesday, June 2, 2010

Page 104: s new in Maven 3 - Jazoon

!Polyglot Maven!Homepage! http://polyglot.sonatype.org/

!Source Code! http://github.com/sonatype/polyglot-maven

!Wiki! https://docs.sonatype.org/display/PMAVEN/

!Groovy Macros! https://docs.sonatype.org/display/PMAVEN/Groovy

Wednesday, June 2, 2010

Page 105: s new in Maven 3 - Jazoon

!M2Eclipse!Homepage! http://m2eclipse.sonatype.org/

!Update Sites! http://m2eclipse.sonatype.org/sites/m2e! http://m2eclipse.sonatype.org/sites/m2e-extras

Wednesday, June 2, 2010