s new in maven 3 - jazoon

Post on 22-Jun-2022

3 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Maven 3.0What’s new in

by Matthew McCullough, Ambient Ideas, LLC

Wednesday, June 2, 2010

In the beginner’s mind there aremany possibilities.

In the expert’s mind there are few.

Wednesday, June 2, 2010

This Talk

Wednesday, June 2, 2010

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

TheRoadmap

Wednesday, June 2, 2010

Wednesday, June 2, 2010

3.0

Wednesday, June 2, 2010

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

!450+ integration tests

Wednesday, June 2, 2010

Wednesday, June 2, 2010

Wednesday, June 2, 2010

Wednesday, June 2, 2010

603!

Wednesday, June 2, 2010

Speed!Performance tuned!Benchmarks

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

Wednesday, June 2, 2010

Maven Speed Test

Wednesday, June 2, 2010

Wednesday, June 2, 2010

Quick! Faster execution! 10% faster in the demo

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

Wednesday, June 2, 2010

Wednesday, June 2, 2010

Efficient! Memory conservative! 73% less in the demo

! Tuned data structures

Wednesday, June 2, 2010

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

Code

Wednesday, June 2, 2010

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

!Basis for derived tools

Wednesday, June 2, 2010

How can you keep up with Maven 3?

Wednesday, June 2, 2010

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

Wednesday, June 2, 2010

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

Wednesday, June 2, 2010

POMs & Maven 3.0

Wednesday, June 2, 2010

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

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

POM XML Validations

!Warns when plugin versions are not specified

Wednesday, June 2, 2010

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

“Duplicate dependency” error

Wednesday, June 2, 2010

Help URLs

! Wiki page URLs now shown for all error messages

Wednesday, June 2, 2010

Help URLs

! Wiki page URLs now shown for all error messages

Wednesday, June 2, 2010

Wednesday, June 2, 2010

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

<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

<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

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

Wednesday, June 2, 2010

Profiles Consolidated

•Profiles.xml external file support removed

•Folded into pom.xml

•Already a best-practice

•Necessary for Polyglot Maven

Wednesday, June 2, 2010

Artifact Behavior Changes

Wednesday, June 2, 2010

Maven 1.0 Deprecated

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

Wednesday, June 2, 2010

SNAPSHOT Datestamps

•Deprecated <uniqueVersion> false </uniqueVersion>

•SNAPSHOTs now always deployed with date-stamps

Wednesday, June 2, 2010

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

Plugin Behavior Changes

Wednesday, June 2, 2010

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

!Affects command-line invocation of plugins

Wednesday, June 2, 2010

#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

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

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

pom.xml

Wednesday, June 2, 2010

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

pom.xml

Wednesday, June 2, 2010

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

Wednesday, June 2, 2010

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

Wednesday, June 2, 2010

toolchainWednesday, June 2, 2010

What is toolchain?

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

Wednesday, June 2, 2010

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

<?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

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

...<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

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

Benefits

!Minimizes plugin configuration!Separates JDK selection from Maven core

Wednesday, June 2, 2010

mvnshellWednesday, June 2, 2010

http://shell.sonatype.org/

Wednesday, June 2, 2010

Wednesday, June 2, 2010

Wednesday, June 2, 2010

What is mvnshell?

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

Wednesday, June 2, 2010

Wednesday, June 2, 2010

Speed of Builds

Wednesday, June 2, 2010

Performance of Shell

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

Wednesday, June 2, 2010

Wednesday, June 2, 2010

polyglotWednesday, June 2, 2010

http://polyglot.sonatype.org/

Wednesday, June 2, 2010

http://polyglot.sonatype.org/

Wednesday, June 2, 2010

Wednesday, June 2, 2010

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

What is polyglot Maven?

!POM file converter!translate tool

!Any-to-Any language translation

Wednesday, June 2, 2010

<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

<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

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

(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

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

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

Polyglot DSLs

!A true DSL framework!Maven lifecycle hooks

!Can modify execution plan!Supplement the lifecycle

Wednesday, June 2, 2010

Polyglot Macros

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

!No freeform scripting (yet)

Wednesday, June 2, 2010

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

Where did we start from again?

Wednesday, June 2, 2010

<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

M2EclipseWednesday, June 2, 2010

Wednesday, June 2, 2010

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

Eclipse Versions Supported

!3.4!3.5!3.5.1 !(Recommended)

!3.6!! ! (Beta)

Wednesday, June 2, 2010

Dependencies

! Visualizes conflicts! Graph and text form

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

Wednesday, June 2, 2010

Dependencies

! Easy exclusions! Uses Eclipse refactoring engine

Wednesday, June 2, 2010

Wednesday, June 2, 2010

Class Search

! Search the entire central repository for! Artifact

! Package

! Classname

! Lucene database! Incremental updates

Wednesday, June 2, 2010

Class Search

Wednesday, June 2, 2010

Wednesday, June 2, 2010

Maven 3.1Wednesday, June 2, 2010

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

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

SummaryWednesday, June 2, 2010

Summary•Validations

•Performance

•Compatibility

•Toolchain

•Shell

•Polyglot

•M2Eclipse

Wednesday, June 2, 2010

Maven 3.0What’s new in

EmailTwitterBlog

Matthew McCulloughmatthewm@ambientideas.com@matthewmccullhttp://ambientideas.com/blog

Wednesday, June 2, 2010

ReferencesWednesday, June 2, 2010

!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

!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

!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

!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

!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

top related