maven Build System Making Projects Make Sense

Similar documents
Maven in the wild. An introduction to Maven

Content. Development Tools 2(57)

Apache Maven. Created by anova r&d bvba

DevOps and Maven. Eamonn de Leastar Dr. Siobhán Drohan Produced by:

What is Maven? Apache Maven is a software project management and comprehension tool (build, test, packaging, reporting, site, deploy).

Pour aller plus loin : Programmation outillée

MAVEN MOCK TEST MAVEN MOCK TEST I

Maven. INF5750/ Lecture 2 (Part II)

Topics covered. Introduction to Maven Maven for Dependency Management Maven Lifecycles and Plugins Hands on session. Maven 2

... Maven.... The Apache Maven Project

MAVEN INTERVIEW QUESTIONS

MAVEN MOCK TEST MAVEN MOCK TEST IV

Apache Maven MarsJUG. Arnaud Héritier exo platform Software Factory Manager

Simplified Build Management with Maven

I Got My Mojo Workin'

Apache Maven: Best Practices

Sonatype CLM Enforcement Points - Nexus. Sonatype CLM Enforcement Points - Nexus

Repository Management and Sonatype Nexus. Repository Management and Sonatype Nexus

The Maven 2 POM demystified

Maven 2 & Continuum. by Trygve Laugstøl

Maven POM project modelversion groupid artifactid packaging version name

Construction: version control and system building

TOP REASONS WHY YOU SHOULD SWITCH TO MAVEN 3

Set up Maven plugins in Eclipse. Creating a new project

Unable To The Artifact From Any Repository Maven-clean-plugin

Software Building (Sestavování aplikací)

BUILD AND DEPLOY SOA PROJECTS FROM DEVELOPER CLOUD SERVICE TO ORACLE SOA CLOUD SERVICE

BUILD AND DEPLOY ORACLE SERVICE BUS PROJECTS FROM ORACLE DEVELOPER CLOUD SERVICE TO ORACLE SOA CLOUD SERVICE USING THE ORACLE SERVICE BUS PLUG-IN

Distributing JavaFX Applications with Java WebStart and Artifactory

Sonatype CLM - IDE User Guide. Sonatype CLM - IDE User Guide

4. Check the site specified in previous step to work with, expand Maven osgi-bundles, and select slf4j.api,

Setting up a Maven Project

Produced by. Agile Software Development. Eamonn de Leastar

... Fisheye Crucible Bamboo

Why switch exist-db from Ant to Maven?

Apache Maven. Péter Jeszenszky Faculty of Informatics, University of Debrecen Last modified: March 8, 2018

Package Management and Build Tools

Overall Design of SSS Software

Fat / Uber jars - Using the Shade Plugin

Session 24. Spring Framework Introduction. Reading & Reference. dev.to/lechatthecat/how-to-use-spring-boot-java-web-framework-withintellij-idea-202p

Funambol Connector Development Tutorial

Nexus for Component Management. Nexus for Component Management

... Apache Maven PDF Plugin v. 1.4 User Guide.... The Apache Software Foundation

Red Hat JBoss Fuse 6.0

gradle : Building Android Apps Mobel Meetup

Oracle Corporation

Tattletale. What is Tattletale? Enterprise archives JBoss Application Server 7 Putting it all together Roadmap

Maven Introduction to Concepts: POM, Dependencies, Plugins, Phases

Hello Maven. TestNG, Eclipse, IntelliJ IDEA. Óbuda University, Java Enterprise Edition John von Neumann Faculty of Informatics Lab 2.

sites</distribsiteroot>

MAVEN MOCK TEST MAVEN MOCK TEST III

Administering Apache Geronimo With Custom Server Assemblies and Maven. David Jencks

Introduction to project industrialization using Maven YaJUG 06/10/2009. Copyright Pierre-Antoine Grégoire License Creative Commons 2.

Red Hat JBoss Enterprise Application Platform 7.1

Packaging, automation, Continuous Integration

Who Moved My Module? 1

Gant as Ant and Maven Replacement

CONTINUOUS DELIVERY IN THE ORACLE CLOUD

Geronimo Server Release Process

#jenkinsconf. Jenkins user plugin. This time it's. Jenkins User Conference Israel. Shiran JFrog

Apache Isis Maven plugin

Spring Persistence. with Hibernate PAUL TEPPER FISHER BRIAN D. MURPHY

Sonatype CLM - CI User Guide. Sonatype CLM - CI User Guide

Software Engineering - Development Infrastructure 2. Kristjan Talvar Nortal

Red Hat JBoss Enterprise Application Platform 6.4

Cheat Sheet: Wildfly Swarm

GlassFish V3 Engineer's guide

Adapting JDT to the Cloud. Alex Boyko Pivotal Jay Arthanareeswaran - IBM John Arthorne - IBM

MANUAL DO ALUNO DE ENGENHARIA DE SOFTWARE

JAVA COURSES. Empowering Innovation. DN InfoTech Pvt. Ltd. H-151, Sector 63, Noida, UP

Maven 2 The powerful buildsystem. a presentation for EL4J developers by Martin Zeltner (MZE) November 2007

Getting started with Geomajas. Geomajas Developers and Geosparc

Continuous Integration INRIA

Apache Karaf Cave 4.x - Documentation

Gradle Leveraging Groovy for Building Java Applications. Hans Dockter Gradle Project Lead

Deploying the JBoss Portfolio to the Cloud

MAVEN SUCKS NO(W) REALLY

Checking Out and Building Felix with NetBeans

Red Hat JBoss Fuse 6.2

ROS-M Summary NDIA GRCC 2017

Oracle Code Day Hands On Labs (HOL) (Install, Repository, Local Deploy, DevCS, OACCS)

Red Hat JBoss Data Grid 7.2

Managing Installations and Provisioning of OSGi Applications. Carsten Ziegeler

JAVA V Tools in JDK Java, winter semester ,2017 1

An Architecture for Self-Organizing Continuous Delivery Pipelines

Red Hat JBoss Fuse 6.1

Build Automation Kurt Christensen

Xmlbeans-maven-plugin Xml Error Loading Schem

Repository Management with Nexus

Jenkins User Conference Israel. #jenkinsconf. CI / Liveperson. Gidi Samuels. July 16, #jenkinsconf

GRAPHSJ 3: A MODERN DIDACTIC APPLICATION FOR GRAPH ALGORITHMS

Struts 2 Maven Archetypes

HBASE Performance test by YCSB

ONAP Developer Typical Setup 2017 July ONAP Virtual Developers Event

FROM NOTHING TO COMPLETE ENVIRONMENT WITH MAVEN, OOMPH & DOCKER. Max Bureck, 21. June 2017

Red Hat JBoss Data Virtualization 6.2

TIBCO StreamBase 10.2 Building and Running Applications in Studio, Studio Projects and Project Structure. November 2017

Red Hat Fuse 7.0 Installing on Apache Karaf

Thomas Pelaia II, Ph.D. XAL Workshop 2012 December 13, 2012 Managed by UT-Battelle for the Department of Energy

HP Operations Orchestration

Transcription:

maven Build System Making Projects Make Sense

Maven Special High Intensity Training

Zen Questions Why are we here? What is a project? What is Maven? What is good? What is the sound of one hand clapping?

Zen Questions Why are we here? What is a project? What is Maven? What is good? What is the sound of one hand clapping?

A software project is 1 or more files with some ultimate purpose In Maven this means A POM giving a file structure purpose The ultimate purpose being an artifact (JAR, WAR, POM, etc.)

POM Project Object Model Objectifies a project Simplifies a build infrastructure

A build infrastructure is A collection of tools, process and conventions for managing projects Management Version control Code Compilation/Generation Tools Continuous Integration Constraint Best practices Pre-defined project structure

Zen Questions Why are we here? What is a project? What is Maven? What is good? What is the sound of one hand clapping?

Maven is Build and Dependency tool Conceptually elegant (avoids Ant s pitfalls): Declarative. Build complexity doesn t correlate to configuration size Network portability Integrated Dependency Management (unlike Ivy): Object-oriented Site and Document management tool Project organization and Plugin framework Thriving Community Active developer and user community 9+ Gigs of projects in Maven public repository

Maven's Objectives Create Standards and Best Practices for healthy and flexible build infrastructures Why only standard APIs and best practices when developing applications? Maven pushes this practice down to the build infrastructure Nourish stable build infrastructures that persevere under high degrees of flux: build with Plexus IoC for increased flexibility Vastly simplify project relationships Via inheritance and dependency management Increase project portability With Maven-managed local and remote repositories

Maven Framework Based on a community of industry experience Creates a standard infrastructure for Code/Configuration Generation Provisioning Building Testing Releasing Issue/Task Management Artifact/Asset Management Documentation Continuous Integration IDE Integration

What Maven really is Model for software projects Patterns for software development and development infrastructures Ultimately the basis for a new form of team collaboration 12

Zen Questions Why are we here? What is a project? What is Maven? What is good? What is the sound of one hand clapping?

Maven was built assuming these are good Intentional infrastructure You must invest in your infrastructure to yield returns It must be carefully planned, infrastructures don t just happen Long-term sustainability The key is keeping people involved sustainability by virtue versus sustainability by force Healthy growth Some constraints are necessary Style is a constraint that reduces erratic behaviors Promotion of community Create opportunities for people to interact

Maven Achieves These By Model-Driven Development Project Object Model (POM) Standard build lifecycles Convention over Configuration Standard directory layout One primary artifact per build Naming conventions Encapsulate and Reuse build logic Maven is a plugin execution framework All build logic is encapsulated in plugins Coherent Organization of dependencies

A consistent model and patterns makes Automation easier Releasing Continuous Integration IDE Workspace Materialization Tooling easier Dependency metadata Plugin metadata Standard lifecycle Real dependency analysis possible 16

Zen Questions Why are we here? What is a project? What is Maven? What is good? What is the sound of one hand clapping?

The sound of one hand clapping [INFO] ---------------------------------------------------------------------------- [INFO] Building JBoss AOP MC Integration [INFO] task-segment: [install] [INFO] ---------------------------------------------------------------------------- [INFO] [resources:resources] [INFO] Error for project: JBoss AOP MC Integration (during install) [INFO] ------------------------------------------------------------------------ [INFO] Failed to resolve artifact. Missing: ---------- 1) org.jboss.micro:kernel:jar:2.0.0-beta-snapshot Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=org.jboss.micro -DartifactId=kernel \ -Dversion=2.0.0-beta-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file Path to dependency: 1) org.jboss.micro:aop-mc-int:jar:2.0.0-beta-snapshot 2) org.jboss.micro:kernel:jar:2.0.0-beta-snapshot ---------- 1 required artifact is missing. for artifact: org.jboss.micro:aop-mc-int:jar:2.0.0-beta-snapshot from the specified remote repositories: central (http://repo1.maven.org/maven2), jboss (http://repository.jboss.com/maven2) build [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] BUILD ERRORS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 8 seconds [INFO] Finished at: Mon Mar 12 00:26:53 CDT 2007 [INFO] Final Memory: 7M/13M [INFO] ------------------------------------------------------------------------ crashing <= missing dependency <= how to install it <= who needs it <= where Maven looked

Zen Questions Why are we here? What is a project? What is Maven? What is good? What is the sound of one hand clapping? So... what is a project?

The POM Project Object Model Declarative definition Size of the POM not necessarily correlated to task amount Objectifies a collection of project files as a single unit with a single artifact output Defines how projects are related to each other (even transitively) Contains physical and conceptual project information Build lifecycle hints, Plugin configurations Developers involved Convention over configuration Our goal is to pre-configure for 95% of use-cases

The POM Licenses Dependencies Extensions Developers/ Contributors Plugins Organization POM Source Control Issue Management Environment Settings Continuous Integration Reporting Contact Information

The POM: Sample <project> <groupid>com.company-x</groupid> <artifactid>my-app</artifactid> <version>1.0-beta-2</version> <packaging>jar</packaging> <name>my JAR Application</name> <dependencies> <dependency> <groupid>org.opensource-y</groupid> <artifactid>parent-app-y</artifactid> <version>3.2.1</version> <dependency> </dependencies> </project> Just set it and forget it!

Project Relationships Super POM = Dependancy = Transitive Dependancy = Module of = Inherits from killerapp killerapp-stores killerapp-api killerapp-model 23

Dependencies = Dependancy = Transitive Dependancy killerapp-stores killerapp-api killerapp-model 24

Inheritance = Inherits from killerapp killerapp-stores killerapp-api killerapp-model 25

Inheritance: Super POM Super POM = Inherits from killerapp killerapp-stores killerapp-api killerapp-model 26

<project> <modelversion>4.0.0</modelversion> <name>maven Default Project</name> <repositories> <repository> <id>central</id> <name>maven Repository</name> <layout>default</layout> <url>http:// repo1.maven.org/maven2</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginrepositories> <pluginrepository> <id>central</id> <name>maven Plugin Repository</name> <url>http:// repo1.maven.org/maven2</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> <releases> <updatepolicy>never</updatepolicy> </releases> </pluginrepository> </pluginrepositories> <build> <directory>target</directory> <outputdirectory>target/classes</outputdirectory> <finalname>${artifactid}-${version}</finalname> <testoutputdirectory>target/test-classes</testoutputdirectory> <sourcedirectory>src/main/java</sourcedirectory> <scriptsourcedirectory>src/main/scripts</scriptsourcedirectory> <testsourcedirectory>src/test/java</testsourcedirectory> <resources> <resource> <directory>src/main/resources</directory> </resource> </resources> <testresources> <testresource> <directory>src/test/resources</directory> </testresource> </testresources> </build> Super POM 27 <reporting> <outputdirectory>target/site</outputdirectory> </reporting> <profiles> <profile> <id>release-profile</id> <activation> <property> <name>performrelease</name> <value>true</value> </property> </activation> <build> <plugins> <plugin> <inherited>true</inherited> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-source-plugin</artifactid> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <plugin> <inherited>true</inherited> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-javadoc-plugin</artifactid> <executions> <execution> <id>attach-javadocs</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <plugin> <inherited>true</inherited> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-deploy-plugin</artifactid> <configuration> <updatereleaseinfo>true</updatereleaseinfo> </configuration> </plugin> </plugins> </build> </profile> </profiles> </project>

Multi-modules = Module of killerapp killerapp-stores killerapp-api killerapp-model 28

Project Relationships Super POM = Dependancy = Transitive Dependancy = Module of = Inherits from killerapp killerapp-stores killerapp-api killerapp-model 29

The POM Details: Artifacts Artifacts are the output of plugin goal actions on project files These are JARs, WARs, etc but can just as easily be a directory of class files Ultimately your build should shoot for 1 artifact Best practice If your project creates more than one artifact, break it up!

Plugins Perform Actions Maven is built as a plugin execution framework The unit of work in a plugin is a goal Actions are declared and self-contained Plugins are applied to a Maven project Projects and artifacts correspond to nouns; Plugins goals correspond to verbs. Compile the project s Java files Package the classes Run the unit tests Plugins are concerned with the how, so project management can concern itself with the what.

Action Details: Goal Execution mvn compiler:compile plugin goal

Action Details: The Build Lifecycle A sequence of goal executions Pre-defined by POM s packaging type Phases are configurable Can create custom types ergo, custom lifecycle configurations Goals are bound to phases

Phases process-resources Goals resources:resources compile compiler:compile process-classes process-test-resources resources:testresources test-compile compiler:testcompile test surefire:test prepare-package package jar:jar 34

Action Details: Running Phases Running a phase will execute all phases up to and including the one specified for the correct packaging type s build lifecycle definition

Action Details: Running Phases Running mvn test no colon (only individual goals have colons) phase Actually runs: Phases: process-resources compile process-test-resources test-compile test Goals: resources:resources compiler:compile resources:testresources compiler:testcompile surefire:test

The Repository: It s not Magic Maven organizes and makes available dependencies and project tools for you just ask Say what you need; not where/how to get it Dependencies in Maven are requested in a declarative fashion Artifacts and Repositories Remote repository is for the portability of dependencies Local repository is a developer s personal cache of downloaded or installed dependencies

From POM to Artifact (using Repository)

Questions?

More Reading Web http://maven.apache.org/guides/ http://maven.apache.org/articles.html Examples http://s3.amazonaws.com/maven2/index.html Books Better Builds with Maven (http://devzuz.com) Maven: The Definitive Guide (http://sonatype.com/book) Java Power Tools (John Smart Dec. 2007) Me http://blog.propellors.net