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

Similar documents
MAVEN INTERVIEW QUESTIONS

MAVEN MOCK TEST MAVEN MOCK TEST I

Maven. INF5750/ Lecture 2 (Part II)

Apache Maven. Created by anova r&d bvba

Simplified Build Management with Maven

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

I Got My Mojo Workin'

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

Repository Management and Sonatype Nexus. Repository Management and Sonatype Nexus

Package Management and Build Tools

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

Maven POM project modelversion groupid artifactid packaging version name

Build Automation Kurt Christensen

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

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

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

MAVEN MOCK TEST MAVEN MOCK TEST III

Component based Development. Table of Contents. Notes. Notes. Notes. Web Application Development. Zsolt Tóth

Maven 2 & Continuum. by Trygve Laugstøl

Junit. Presentation & Tools (Eclipse, Maven, Mockito, Spring)

... Fisheye Crucible Bamboo

Software Engineering - Development Infrastructure 2. Kristjan Talvar Nortal

Maven in the wild. An introduction to Maven

MAVEN MOCK TEST MAVEN MOCK TEST IV

This tutorial explains how you can use Gradle as a build automation tool for Java as well as Groovy projects.

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

Content. Development Tools 2(57)

JDO Tools Guide (v5.1)

Selenium Testing Course Content

Build Tools. Software Engineering SS A tool was needed. Agenda for today. Build tools. Software complexity. Build tools

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

Build Tools. Software Engineering SS 2007

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

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

sites</distribsiteroot>

Pour aller plus loin : Programmation outillée

AUTOMATION TESTING FRAMEWORK FOR LUMINOUS LMS

JPA Enhancement Guide (v5.1)

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

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

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

JPA Tools Guide (v5.0)

The Workshop. Slides (you have a copy in the zip) Practical labs Ask questions

Cheat Sheet: Wildfly Swarm

Getting started with Geomajas. Geomajas Developers and Geosparc

TOP REASONS WHY YOU SHOULD SWITCH TO MAVEN 3

Tuscany: Applying OSGi modularity after the fact

vrealize Code Stream Plug-In SDK Development Guide

Packaging, automation, Continuous Integration

The Actual Real World at EclipseCon/ALM

Software Building (Sestavování aplikací)

Chapter 1. Installation and Setup

Apache Maven: Best Practices

EMC Documentum Composer

Struts 2 Maven Archetypes

Apache Buildr in Action

Problem Set 0. General Instructions

JBoss Tattletale 1.1 Developer's Guide

Maven Plugin Guide OpenL Tablets BRMS Release 5.16

Why switch exist-db from Ant to Maven?

Getting Started with Gradle

Enter the Gradle Hans Dockter CEO, Gradleware Founder Gradle

C++ Binary Dependency Management with Gradle. Hugh Greene

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

APEX Developer Guide. Sven van der Meer, Liam Fallon, John Keeney. Version SNAPSHOT, T11:44:57Z

gradle : Building Android Apps Mobel Meetup

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

m2e 1.2 Release Review

Red Hat JBoss Web Server 3.1

Contents. Enterprise Systems Maven and Log4j. Maven. What is maven?

SELENIUM. SELENIUM COMPONENTS Selenium IDE Selenium RC Selenium Web Driver Selenium Grid

Setting up a Maven Project

Breaking Apart the Monolith with Modularity and Microservices CON3127

We d like to hear your suggestions for improving our indexes. Send to

What s new in IBM Operational Decision Manager 8.9 Standard Edition

Action Developers Guide

Nexus for Component Management. Nexus for Component Management

APEX Installation Guide. Sven van der Meer, Liam Fallon, John Keeney. Version SNAPSHOT, T16:01:13Z

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

Groovy. Extending Java with scripting capabilities. Last updated: 10 July 2017

JenkinsPipelineUnit. Test your Continuous Delivery Pipeline. Ozan Gunalp - Emmanuel Quincerot

SCA Java Runtime Overview

Produced by. Agile Software Development. Eamonn de Leastar

7.1. RELEASE-NOTES-2.0-M1.TXT

Class 1 Introduction to Selenium, Software Test Life Cycle.

Checking Out and Building Felix with NetBeans

Mobiliser CODE GENERATION - DAO-2-Service

SELENIUM TRAINING COURSE CONTENT

Info Error Deploying Artifact Failed To Transfer File Return Code Is 401

Introducere in Maven. Information Type: Working Standard, Disclosure Range:, Information Owner: mihai.hulea, NTT DATA Romania

Lab 5 Exercise Build and continuous integration tools

Version Control. Kyungbaek Kim. Chonnam National University School of Electronics and Computer Engineering. Original slides from James Brucker

1. The Apache Derby database

An Integrated Approach to Managing Windchill Customizations. Todd Baltes Lead PLM Technical Architect SRAM

JVM Survival Guide. Hadi Hariri

Tim O'Brien (Sonatype, Inc.), John Casey (Sonatype, Inc.), Brian Fox (Sonatype, Inc.), Bruce Snyder (Sonatype, Inc.), Jason Van Zyl (Sonatype, Inc.

<put document name here> 1/13

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

ONAP Developer Typical Setup 2017 July ONAP Virtual Developers Event

Effective Testing of Local Git Branches Using Remote Execution

Transcription:

arnaud.nauwynck@gmail.com Maven Introduction to Concepts: POM, Dependencies, Plugins, Phases This document: http://arnaud-nauwynck.github.io/docs/maven-intro-concepts.pdf

31 M!! What is Maven?

https://maven.apache.org/

A software project management and comprehension tool. Based on a project object model (POM),.. project's build, reporting and documentation..

https://maven.apache.org/guides/getting-started/maven-in-five-minutes.htm l

https://maven.apache.org/guides/getting-started/maven-in-five-minutes.htm l

Wikipedia

Maven is a Build Automation Tool pom.xml <dependencies> <plugins> <packaging> <phase>

1st, it describes how software is built, 2nd, it describes its dependencies. use conventions for build

Ant = portable Make in xml for Javac, Jar,.. 2005 2007 2010 Maven 1 Maven 2 = Ant + Jelly = Java Mojo = xml build tasks pom.xml + scripts (<if>, <var>..) + rules / lifecycle Ma ve n5 Ma ve n3 2002 ad le Ma ve n1 2000 Gr An t 1977 Ma ve n2 Ma ke file? Maven History 2017? Maven 3?? Split = better & compatible pom vs build optional.mvnw => pom in yaml, groovy,.. ( not widespread ) Yaml / groovy

Authors, Company, Community Jason Van Zyl Worked on Turbine Author of - Velocity - Maven Sonatype Company ( core Contributor + Product = Nexus ) Apache Fondation = Open Source Community founder of Sonatype PMC Chair / Member / Contributor / Plugin-Developpers / Users

Maven Adoption 68% uses maven It JUST Work!! 4.5 Millions published artifacts (=jars)

Yet Another Build Tool Makefile, Imake, Cmake, Ant, Maven, Gradle, MsBuild, Sbt, Gulp, Grunt,...

Declarative vs Imperative Describe WHAT not HOW

Imperative Do 1/ This, Then 2/ That, Then 3/ Also That And N/ You have finished you want to restart?

Implicit Convention over Configuration Given standards When You follow them Then it just works

Implicit Convention over Configuration a Java Program is src/*.java files compiled in classes/*.class using javac + classpath assembled in jar file tested with Junit test bla bla bla

Implicit + Declarative = Surprising Magic...

Maven Core Concepts 1 : (declarative) Project Object Model

Mandatory GAV Declaration Unique ID : GAV = Group / Artifact / Version Group = like dns domain name, reverse com.<<company>>, org.<<...>>, <<country>>.<<...>>.... Artifact = name of the final jar naming convention: some-library-name Version = major.minor.fix (-SNAPSHOT)?

Optional Project Information

Example Project Information

Typical Maven Generated Site Then you recognise pom infos Menu when you see this logo Logo comes from maven (maven-site-plugin )

Basic Declarations

Maven Core Concepts 2 : Dependencies

Dependency Declaration Describe WHAT First execution: Download Not HOW Next execution: reuse local repository file

WHERE? http://maven.search.org

Transitive Dependencies Transitive Relation Definition: A B and B C.. then A C

Transitive Dependencies Conflicts B D version1 A C D version2!= 1

Dependencies Omitted for Conflict Given Java ClassLoader load once each class When you have conflict Then 1 jar on 2 would be useless, Maven omit oldest jar version

Can Override default configuration Override to use specific version Override to exclude dependency

DependencyManagement avoid duplicate version, use parent

Dependency Scopes compile *.jar system *.jar provided *.jar Compile src/ main/java/**.java src/ test/java/**.java Provided *.jar target/ target/ classes/**.class *.jar Test target/ test-classes/**.class Runtime

Dependency Summary Would be more concise than xml: junit:junit:4.12:test Use dependencymanagement versions in parent only don't be too verbose transitive dependencies => implicit don't be too implicit use exact versions, not *

Example Getting Started with Mvn & Eclipse

Maven Tools Usages In Command Line In IDE Eclipse Buit-in support In CI Server Jenkins.. Built-in support

Maven Tools Usages In Command Line In IDE Eclipse Buit-in support In CI Server Jenkins.. Built-in support

Installation= Unzip + export PATH 1: Unzip 2: export JAVA_HOME & PATH

Mvn command line mvn install

mvn clean install mvn install -f../pom.xml -o -DskipTests -Pprofile... Pl ug in G oa ls W ith op t io ns Si m pl e ph as es Typical Commands mvn springboot:run

Start Edit a Pom.xml manually? XML = Langage for Computers not for Humans You only need this identity card : GAV = group / artifact / version

New Maven Project Copy & Paste mvn archetype:generate New Project... > mvn install mvn install Import existing project > Type : maven Type: Maven Project Choose archetype... mvn install

Eclipse Import Existing Maven Project

First Maven Project in Eclipse

Pom.xml

Standard Source Project Layout

Mvn compile (or install)

src target directories src compile src/main/java target/classes compile-test target src/test/java target/test-classes jar target/classes target/*.jar install target/*.jar ~/.m2/repository/... groupid/artifactid/version/*.jar deploy.m2/repository/...jar http://nexus-repo/... groupid/artifactid/version/*.jar

Mvn clean src vs target +.gitignore

Typical.gitignore for target/,.project,.classpath,...

Project Layout Explained by Dichotomy Questions src/** + pom.xml +.gitignore Dir / File Stored In SCM or Generated (or ignored)? target/**.git/**.classpath.project.settings

Project Layout Explained (bis) src/main/** src/** Main or test? src/test/** Dir / File target/**

Project Layout Explained (ter) src/main src Dir / File src/test target Lang? java resources python doc webapp

Maven Core Concepts 3 : Plugins Goals

https://maven.apache.org/plugins/ Scroll for 100 more

.m2/repository/org/apache/maven First launch mvn will download ~150Mo... Plugins...

Maven.m2/repository/ /plugins standard plugins in local repository

Use build/plugins Use plugin Use Another Declare plugin Dependencies with GAV ( as build dependencies but in section plugins) => Plugin will register itself in build lifecycle see next for configuring..

Plugin <configuration> Override plugin configuration <source> = -source for javac compiler list of options => cf next

Eclipse Auto-Completion for Plugin Configuration

Maven Plugin Doc Site https://maven.apache.org/plugins See Plugin Goals & Usage In 2016 default value to change for jdk8!!

Configuration Override Properties Project properties

Properties Override Hierarchy (bis) User ~/.m2/settings.xml override Project properties override Command Line arguments

plugins/executions When processing lifecycle phase 1 execution Then call plugin goal With this parameter Can add others...

Plugin Execution Override Project properties override plugin configuration override Execution configuration

Command Line Explicit Plugin Goal Execution Call build lifecycle 1..* phase(s) => sequence of plugin goals Call explicit 1..* plugin goal(s)

Example of Plugin Goals

Plugin Internal Mojo Classes as simple as a main() executed within a project build context

Run Mojo Hello World...

Mojo Context Injection @Parameter Inject from <configuration><sources>.. default properties for values Inject the FAMOUS pom

Maven Core Concepts 4 : Build Lifecycle - Phases

Maven Phases

Register Goals Execution in Phases Explicit Goal Execution per <phase> Implicit Goal Execution per Phase

Project Type LifeCycle Phases Plugins Mojo repository/org/apache/maven/plugins/ Maven-jar-plugin-3.0.2.jar META-INF/plexus/components.xml

Conclusion Questions? arnaud.nauwynck@gmail.com Only a Short Introduction to Concepts... other docs: http://arnaud-nauwynck.github.io/ http://arnaud.nauwynck.free.fr/ This document: http://arnaud-nauwynck.github.io/docs/maven-intro-concepts.pdf