efficient enterprise builds with apache maven

32
Efficient Enterprise Builds With Apache Maven Jason van Zyl Sonatype Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 1

Upload: others

Post on 03-Feb-2022

24 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Efficient Enterprise Builds With Apache Maven

Efficient Enterprise Builds With Apache MavenJason van ZylSonatype

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 1

Page 2: Efficient Enterprise Builds With Apache Maven

It is usually assumed the infrastructure for a project is fine, but it is often the source of many problems because that assumption is false.

It is critical that the infrastructure for a project be sound in order for a project to succeed.

Importance of Infrastructure

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 2

Page 3: Efficient Enterprise Builds With Apache Maven

What is Maven?Build tool

Similar to Make, or Ant, but fundamentally different in that a larger context is considered

Dependency management toolSimilar to Ivy, but not bolted on as an afterthought

Site management tool

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 3

Page 4: Efficient Enterprise Builds With Apache Maven

What maven really is ...Model for software projectsPatterns for software development and development infrastructuresUltimately the basis for a new form of team collaboration

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 4

Page 5: Efficient Enterprise Builds With Apache Maven

POM

Mailing ListsDistribution

ManagementIssue Management

Source Control Management

Continuous Integration

Dependencies

Organizational Information

Reporting

Developers Plugins

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 5

Page 6: Efficient Enterprise Builds With Apache Maven

Simple Project Object Model

<project> <modelVersion>4.0.0</modelVersion> <groupId>com.sonatype.killerapp</groupId> <artifactId>superapp</artifactId> <version>1.0-SNAPSHOT</version> <name>Maven Quick Start Archetype</name> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies></project>

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 6

Page 7: Efficient Enterprise Builds With Apache Maven

Super POM

POM POMPOM

POM

POM

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 7

Page 8: Efficient Enterprise Builds With Apache Maven

Validate

Generate Sources

Generate Resources

Compile

Test

Package

Install

Deploy

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 8

Page 9: Efficient Enterprise Builds With Apache Maven

Development Infrastructures

Development Infrastructures must provide facilities for:

BuildingTestingDocumentingContinuous IntegrationReleasingArtifact/Asset ManagementProvisioning

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 9

Page 10: Efficient Enterprise Builds With Apache Maven

A consistent model and patterns makes ...

Automation easierReleasingContinuous IntegrationIDE Bootstrapping

Tooling easierDependency metadataPlugin metadataStandard lifecycle

Real dependency analysis possible

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 10

Page 11: Efficient Enterprise Builds With Apache Maven

Why can’t I just use Ant?You certainly can, but Ant provides no

conventionsmodelsprocessesorder

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 11

Page 12: Efficient Enterprise Builds With Apache Maven

Intentional infrastructureYou have to invest in your infrastructure to yield returnsIt must be carefully planned, infrastructures don’t just happen

Long-term sustainabilityThe key is keeping people involvedsustainability by virtue versus sustainability by force

Healthy growth in mindSome constraints are necessary

Promotion of communityCreate opportunities for people to interact

Infrastructure, Portland, Oregon and Maven

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 12

Page 13: Efficient Enterprise Builds With Apache Maven

Questions about infrastructure

Do you think your infrastructure is wildly different then anyone else’s?Is your infrastructure a competitive advantage?Would you like help with the most difficult infrastructure problems you might face?

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 13

Page 14: Efficient Enterprise Builds With Apache Maven

The infrastructure should provide a lot to make complicated tasks easierWhen complicated tasks are made easy, there is more time for the bigger pictureWhat's in the bigger picture?

Inherent utility

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 14

Page 15: Efficient Enterprise Builds With Apache Maven

Maven & Social CapitalTerm coined by Jane Jacobs (The Death and Life of Great American Cities)People’s ability to work together in groupsCreation of real communities using the idea of patterns and conscious planningConcrete example of the Maven community working together to improve the release process at Apache

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 15

Page 16: Efficient Enterprise Builds With Apache Maven

Apache Release ProcessRequirements

Apache License Legal NoticeDisclaimer for Apache Incubator projectsPGP SignaturesSourcesJavadocs

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 16

Page 17: Efficient Enterprise Builds With Apache Maven

Remote Resources Plugin

Remote Resource Bundle

Remote Resource Bundle

Each bundle can contain one or more resources

VelocityEach resource from each bundle is processed through Velocity. The POM is pushed into theVelocity context.

Add Resource to POM

All resources once processed are placed in${basedir}/target/maven-shared-archive-resourcesand a Resource entry is added to the POM which corresponds to that directory.

Plugins pick up shared resources

Any archiving plugin that is aware of the shared archive resources Resourceentry in the POM can pick them upand insert them into the archive it creates.

The remote resources plugin takes the bundles, puts them in a ClassLoader and hands it off to Velocity.

JARs/WARs/EARsAll archives created by projects using Maven now have their all their legal requirements forpackaging satisfied transparently

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 17

Page 18: Efficient Enterprise Builds With Apache Maven

Standards and Best Practices for build infrastructures

We use standard APIs and best practices when developing applications: Maven pushes this practice down to the level of infrastructure

Provide a shared language for build infrastructure management

Patterns for build infrastructures in the spirit of A

Pattern Language by Christopher Alexander

Create healthy and robust build infrastructures that hold up to high degrees of flux

Maven's Objectives

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 18

Page 19: Efficient Enterprise Builds With Apache Maven

Maven's PrinciplesModel driven developmentConvention over configurationReuse and encapsulation of build logicCoherent organization of dependencies

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 19

Page 20: Efficient Enterprise Builds With Apache Maven

Analogous to MDA where your activities, actions and data model are governed by your architectural model, in Maven at the infrastructural level we try to provide a modelMaven's project object model (POM)Maven's build life cycle

Model driven development

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 20

Page 21: Efficient Enterprise Builds With Apache Maven

POM

Mailing ListsDistribution

ManagementIssue Management

Source Control Management

Continuous Integration

Dependencies

Organizational Information

Reporting

Developers Plugins

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 21

Page 22: Efficient Enterprise Builds With Apache Maven

Simple Project Object Model

<project> <modelVersion>4.0.0</modelVersion> <groupId>com.sonatype.killerapp</groupId> <artifactId>superapp</artifactId> <version>1.0-SNAPSHOT</version> <name>Maven Quick Start Archetype</name> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies></project>

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 22

Page 23: Efficient Enterprise Builds With Apache Maven

Super POM

POM POMPOM

POM

POM

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 23

Page 24: Efficient Enterprise Builds With Apache Maven

Validate

Generate Sources

Generate Resources

Compile

Test

Package

Install

Deploy

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 24

Page 25: Efficient Enterprise Builds With Apache Maven

Standard directory layoutOne primary artifact per buildStandard naming conventions

Convention over configuration

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 25

Page 26: Efficient Enterprise Builds With Apache Maven

All build logic is encapsulated in pluginsMaven is a plugin execution frameworkPlugins can be applied to all Maven projects

Encapsulation and reuse of build logic

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 26

Page 27: Efficient Enterprise Builds With Apache Maven

Say what you need, not where or how to get itDependencies in Maven are requested in a declarative fashion

Artifacts and RepositoriesRemote repositories for the satisfaction of dependenciesLocal repository is the developers personal analog to a set of remote repositories

Coherent organization of dependencies

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 27

Page 28: Efficient Enterprise Builds With Apache Maven

Maven

Local Repository

POM

1

2

3 Remote Repository

Maven checks the local repositoryfor the required dependencies

Maven gathers dependency informationfrom the POM

Maven retrieves the necessary dependenciesfrom the remote repository

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 28

Page 29: Efficient Enterprise Builds With Apache Maven

Coherence – An orderly, logical, and aesthetically consistent relation of partsReusability – Reuse not only of software components but the best practices of an entire industryAgility – Maven allows easier integration and project straddlingMaintainability – Maven projects are more maintainable as there are far fewer surprises

What Maven Provides

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 29

Page 30: Efficient Enterprise Builds With Apache Maven

Relieves the burden of project and build maintenanceEasy for new users to embrace Best PracticesFocus on adding value to your applicationsDraw upon the community for solutions

Benefits of Maven

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 30

Page 31: Efficient Enterprise Builds With Apache Maven

Hands on Demo!We will now convert an Ant project and conceptually map all the aspects of an Ant build to the Maven equivalent so you can see how powerful Maven actually is!

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 31

Page 32: Efficient Enterprise Builds With Apache Maven

Questions?Do have any questions about Maven?

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Sonatype

Jason van Zyl — Efficient Enterprise Builds With Apache Maven Slide 32