SlideShare a Scribd company logo
Titel
Onderwerp
Verantwoordelijke afdeing, personen.
Datum
JTech Accelerator Program 2019
CI-CD DevOps – Advanced Maven
Bert Koorengevel - Java Software Engineer / CodeSmith, Ordina OSD - JTech
@BertKoor
Titel
Onderwerp
Verantwoordelijke afdeing, personen.
Datum
https://karussell.wordpress.com/2009/09/29/
3
Apache Maven
• Apache Software Foundation:
community for Open Source software projects
• Maven: a Yiddish word meaning
“accumulator of knowledge”
• Dominant build tool in the Java world
• Multi-platform (Windows / Unix),
command-line interface
4
• Making the build process easy
• Providing a uniform build system
• Providing quality project information
• Providing guidelines for best practices development
• Allowing transparent migration to new features
Maven Objectives
5
Maven pom.xml
• pom = Project Object Model
• Controls the what and how of the build proces
• What: groupId, artifactId, version,
packaging :
• jar = Java ARchive
• war = Web application ARchive
• ear = Java Enterprise ARchive
• pom = other (produces only the pom.xml) or controlling multi-module builds
• How: we’ll see later, controlled in principle by packaging and plugins
• “Convention over Configuration” : sticking to the conventions reduces configuration
• Convention: the pom.xml is located in the root folder of the project
• Reference documentation: https://maven.apache.org/pom.html
<?xml>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>nl.ordina.jtech</groupId>
<artifactId>MavenDemo</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
</project>
6
Maven Process Flow
‘Target’ folderMaven‘Source’ folder
pom.xml
Artifact
7
WTF is an
Artifact?
8
9
10
What is an Artifact?
• General definition: “any object made by human beings”
• In software: an application, module or component, typically archived (e.g. zip file)
• Storage in a Repository
• artifactId – identifier / name of the artefict
• groupId – serves as Namespace, so the artifactId need not be worldwide unique
• version – artifact versions are frozen. New build  increase version!
• Path in repository: / groupId / artifactId / version / artifactId-version.ext
SportsQuest/nl/ordina/jtech/sportsquest/ /1.2.3/SportsQuest-1.2.3.zip
11
Initializing a simple Maven Project
 Execute:
- mvn archetype:generate -DgroupId=nl.ordina -DartifactId=MyFirstPony
• New projectfolder MyFirstPony
is created, containing:
• Standard folder structure
with 2 java classes
• A pom.xml
12
 Visit https://github.com/IvoNet
 Repo: javaee8-payara-microprofile-archetype
 Generate your own project using this archetype
 Study what is generated
 Study the original pom.xml, how does it work?
Exploring a custom archetype
13
Packaging
• jar = Java ARchive
• war = Web application ARchive
• ear = Java Enterprise Archive
• ejb = Enterprise Java Bean
• pom = other (produces only the pom.xml)
or controlling multi-module builds
• maven-plugin
• maven-archetype
<?xml>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>nl.ordina.jtech</groupId>
<artifactId>MavenDemo</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
</project>
14
 Simple as 1, 2, 3 …
Artifact Versioning
15
Semantic Versioning : https://semver.org
Version: 1
• Major version
• Minor version
• Patch version
• Build number
• or Qualifier
.2.3-45
-SNAPSHOT
16
Maven Build Lifecycle
3 separate lifecycles:
 Clean : discard previous built files (workspace)
 Default : compilation & deployment (Maven repository)
 Site : generation of html reports (code quality, etc)
17
Lifecycle Phases
Each lifecycle consists of phases.
Most important phases of the default lifecycle:
 Compile
 Test
 Package
 Validate
 Install
 Deploy
18
• clean
----------------------------------------------------------------------
| | /| /  / |¯¯¯ | | /¯¯ ¯¯|¯¯ / |¯¯ ¯¯|¯¯ |
| |  / | /__  / |-- |  | ¯¯ | /__ |--/ | |
| | / | /  / |___ | | __/ | /  |  | |
----------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenDemo 0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo ---
[INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget
Convention:
Maven only touches the “target” folder
Slow-Motion …
19
• clean
• validate
• initialize
• generate-sources
• process-sources
• generate-resources
• process-resources
----------------------------------------------------------------------
| | /| /  / |¯¯¯ | | /¯¯ ¯¯|¯¯ / |¯¯ ¯¯|¯¯ |
| |  / | /__  / |-- |  | ¯¯ | /__ |--/ | |
| | / | /  / |___ | | __/ | /  |  | |
----------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenDemo 0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo ---
[INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
Conventions:
Output goes to /target/classes
Resource files are in /src/main/resources
Slow-Motion …
20
• clean
• validate
• initialize
• generate-sources
• process-sources
• generate-resources
• process-resources
• compile
----------------------------------------------------------------------
| | /| /  / |¯¯¯ | | /¯¯ ¯¯|¯¯ / |¯¯ ¯¯|¯¯ |
| |  / | /__  / |-- |  | ¯¯ | /__ |--/ | |
| | / | /  / |___ | | __/ | /  |  | |
----------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenDemo 0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo ---
[INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
----------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenDemo 0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo ---
[INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargetclasses
Convention:
Java source files are in /src/main/java
Slow-Motion …
21
• clean
• validate
• initialize
• generate-sources
• process-sources
• generate-resources
• process-resources
• compile
• process-classes
• generate-test-sources
• process-test-sources
• generate-test-resources
• process-test-resources
----------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenDemo 0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo ---
[INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargetclasses
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenDemo 0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo ---
[INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargetclasses
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MavenDemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
Convention:
Test output goes to /target/test-classes
Test resources are in /src/test/resources
Slow-Motion …
22
• clean
• validate
• initialize
• generate-sources
• process-sources
• generate-resources
• process-resources
• compile
• process-classes
• generate-test-sources
• process-test-sources
• generate-test-resources
• process-test-resources
• test-compile
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenDemo 0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo ---
[INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargetclasses
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MavenDemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo ---
[INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargetclasses
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MavenDemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MavenDemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargettest-classes
Convention:
Test sources are in /src/test/java
Slow-Motion …
23
• clean
• validate
• initialize
• generate-sources
• process-sources
• generate-resources
• process-resources
• compile
• process-classes
• generate-test-sources
• process-test-sources
• generate-test-resources
• process-test-resources
• test-compile
• process-test-classes
• test
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo ---
[INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargetclasses
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MavenDemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MavenDemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargettest-classes
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MavenDemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargettest-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenDemo ---
[INFO] Surefire report directory: C:WorkspaceMavenWorkshopMavenDemotargetsurefire-
reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running HelloMavenTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Results :
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
Slow-Motion …
24
• clean
• validate
• initialize
• generate-sources
• process-sources
• generate-resources
• process-resources
• compile
• process-classes
• generate-test-sources
• process-test-sources
• generate-test-resources
• process-test-resources
• test-compile
• process-test-classes
• test
• prepare-package
• package
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MavenDemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargettest-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenDemo ---
[INFO] Surefire report directory: C:WorkspaceMavenWorkshopMavenDemotargetsurefire-
reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running HelloMavenTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Results :
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenDemo ---
[INFO] Surefire report directory: C:WorkspaceMavenWorkshopMavenDemotargetsurefire-
reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running HelloMavenTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Results :
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MavenDemo ---
[INFO] Building jar: C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar
Slow-Motion …
25
• clean
• validate
• initialize
• generate-sources
• process-sources
• generate-resources
• process-resources
• compile
• process-classes
• generate-test-sources
• process-test-sources
• generate-test-resources
• process-test-resources
• test-compile
• process-test-classes
• test
• prepare-package
• package
• pre-integration-test
• integration-test
• post-integration-test
• verify
• install
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenDemo ---
[INFO] Surefire report directory: C:WorkspaceMavenWorkshopMavenDemotargetsurefire-
reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running HelloMavenTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Results :
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MavenDemo ---
[INFO] Building jar: C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar
T E S T S
-------------------------------------------------------
Running HelloMavenTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Results :
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MavenDemo ---
[INFO] Building jar: C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ MavenDemo ---
[INFO] Installing C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar to
C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.jar
[INFO] Installing C:WorkspaceMavenWorkshopMavenDemopom.xml to
C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.pom
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MavenDemo ---
[INFO] Building jar: C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ MavenDemo ---
[INFO] Installing C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar to
C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.jar
[INFO] Installing C:WorkspaceMavenWorkshopMavenDemopom.xml to
C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.028 s
[INFO] Finished at: 2016-01-20T10:45:32+01:00
[INFO] Final Memory: 16M/159M
[INFO] ------------------------------------------------------------------------
Slow-Motion …
26
• clean
• validate
• initialize
• generate-sources
• process-sources
• generate-resources
• process-resources
• compile
• process-classes
• generate-test-sources
• process-test-sources
• generate-test-resources
• process-test-resources
• test-compile
• process-test-classes
• test
• prepare-package
• package
• pre-integration-test
• integration-test
• post-integration-test
• verify
• install
• deploy
T E S T S
-------------------------------------------------------
Running HelloMavenTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Results :
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MavenDemo ---
[INFO] Building jar: C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ MavenDemo ---
[INFO] Installing C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar to
C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.jar
[INFO] Installing C:WorkspaceMavenWorkshopMavenDemopom.xml to
C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.pom
[INFO] Installing C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar to
C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.jar
[INFO] Installing C:WorkspaceMavenWorkshopMavenDemopom.xml to
C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ MavenDemo ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.232 s
[INFO] Finished at: 2016-01-20T10:41:10+01:00
[INFO] Final Memory: 16M/157M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
(default-deploy) on project MavenDemo: Deployment failed: repository element was not
specified in the POM inside distributionManagement element or in -
DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
“mvn clean install” suffices“mvn clean package” suffices
Slow-Motion …
27
Some Maven Conventions
 Maven only touches the “target” folder
 Locations:
- Java sources: /src/main/java
- Resources: /src/main/resources
- Output: /target/classes
- Test sources: /src/test/java
- Test resources: /src/test/resources
- Test output: /target/test-classes
28
Generic format:
 mvn [ phase | pluginId:goal | -options ] ...
 mvn [groupId:]pluginId[:version]:goal
implicit groupId = org.apache.maven and maven-{pluginId}-plugin
Some examples:
 mvn –v
 mvn archetype:generate -DartifactId=MyFirstPony
 mvn package
 mvn clean package
 mvn help:effective-pom
 mvn dependency:tree
Maven Commandline
29
Properties
<project>
...
<description>My project ${myProperty}</description>
<properties>
<myProperty>has a value</myProperty>
</properties>
mvn [goals] –DmyProperty="has no value"
30
Modules – aggregate build
 The Parent project containing the
modules has packaging “pom”
 Each module sits in its own
subdirectory and is a separate
Maven project that needs to be
built
<modules>
<module>core</module>
<module>model</module>
<module>webservice</module>
</modules>
31
Dependency Management
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
• Declares the version without
actually using the dependency
• Often used in Parent pom’s,
uniformity of versions across the
project
32
Change the build (other plugin behaviour) based on activation:
 Standard activation (activeByDefault)
 Command line activation
- parameter –PprofileName
 Property values
 JDK version
 OS name, family, version
 (in) Existance of a file
Profiles
33
 Just a dependency with Scope = import
 Article by Edwin Derks: “to bom or not to bom”
Importing a BOM pom with Dependency Management
34
 https://ordina-jtech.github.io/MetMavenKunJeAllesBouwen
Workshop – using plugins

More Related Content

PPTX
Ordina Accelerator program 2019 - Quality assurance
PPTX
Ordina Accelerator program 2019 - Jenkins blue ocean pipelines
PPTX
From Ant to Maven to Gradle a tale of CI tools for JVM
PDF
Ant, Maven and Jenkins
PDF
Agile Software Development & Tools
PPTX
Apache Maven
PDF
Continuous delivery-with-maven
Ordina Accelerator program 2019 - Quality assurance
Ordina Accelerator program 2019 - Jenkins blue ocean pipelines
From Ant to Maven to Gradle a tale of CI tools for JVM
Ant, Maven and Jenkins
Agile Software Development & Tools
Apache Maven
Continuous delivery-with-maven

What's hot (20)

PPTX
Continuous delivery applied (DC CI User Group)
PPTX
Delivery Pipeline as Code: using Jenkins 2.0 Pipeline
PPTX
Google jib: Building Java containers without Docker
PPTX
Ci jenkins maven svn
PPTX
PDF
Testing fácil con Docker: Gestiona dependencias y unifica entornos
PPTX
Maven plugins, properties en profiles: Advanced concepts in Maven
PPTX
Maven ppt
PPTX
Learning Maven by Example
PPTX
Maven for Dummies
PPTX
Micronaut: A new way to build microservices
PPTX
Apache Maven for SoftServe IT Academy
PPTX
Introduction to Maven
PPTX
02 - Build and Deployment Management
PPTX
Version Management in Maven
PPTX
An introduction to Maven
PDF
Automated Deployment with Maven - going the whole nine yards
PDF
Developing Liferay Plugins with Maven
PPTX
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
PPTX
Development Tools - Maven
Continuous delivery applied (DC CI User Group)
Delivery Pipeline as Code: using Jenkins 2.0 Pipeline
Google jib: Building Java containers without Docker
Ci jenkins maven svn
Testing fácil con Docker: Gestiona dependencias y unifica entornos
Maven plugins, properties en profiles: Advanced concepts in Maven
Maven ppt
Learning Maven by Example
Maven for Dummies
Micronaut: A new way to build microservices
Apache Maven for SoftServe IT Academy
Introduction to Maven
02 - Build and Deployment Management
Version Management in Maven
An introduction to Maven
Automated Deployment with Maven - going the whole nine yards
Developing Liferay Plugins with Maven
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
Development Tools - Maven
Ad

Similar to Ordina Accelerator program 2019 - Maven (20)

PPTX
Joget Workflow v6 Training Slides - 16 - Preparing Development Environment
PPTX
(Re)-Introduction to Maven
PPT
An introduction to maven gradle and sbt
PDF
Introduction to Maven
PDF
Introduction to maven, its configuration, lifecycle and relationship to JS world
PPTX
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...
PDF
Extending Build to the Client: A Maven User's Guide to Grunt.js
PPT
Using Maven2
PPTX
Apache Maven
ODP
PPTX
Maven Basics - Explained
PPT
Maven: Managing Software Projects for Repeatable Results
PPTX
Apache Maven basics
PPTX
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
PDF
maven
PDF
Java, Eclipse, Maven & JSF tutorial
PPT
PPT
Maven introduction in Mule
PPTX
Maven
PPT
Joget Workflow v6 Training Slides - 16 - Preparing Development Environment
(Re)-Introduction to Maven
An introduction to maven gradle and sbt
Introduction to Maven
Introduction to maven, its configuration, lifecycle and relationship to JS world
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...
Extending Build to the Client: A Maven User's Guide to Grunt.js
Using Maven2
Apache Maven
Maven Basics - Explained
Maven: Managing Software Projects for Repeatable Results
Apache Maven basics
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
maven
Java, Eclipse, Maven & JSF tutorial
Maven introduction in Mule
Maven
Ad

Recently uploaded (20)

PDF
cuic standard and advanced reporting.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Electronic commerce courselecture one. Pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Cloud computing and distributed systems.
PDF
Empathic Computing: Creating Shared Understanding
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
Big Data Technologies - Introduction.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
KodekX | Application Modernization Development
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPT
Teaching material agriculture food technology
PDF
Network Security Unit 5.pdf for BCA BBA.
cuic standard and advanced reporting.pdf
Spectral efficient network and resource selection model in 5G networks
The Rise and Fall of 3GPP – Time for a Sabbatical?
Electronic commerce courselecture one. Pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
“AI and Expert System Decision Support & Business Intelligence Systems”
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Cloud computing and distributed systems.
Empathic Computing: Creating Shared Understanding
NewMind AI Monthly Chronicles - July 2025
Big Data Technologies - Introduction.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
KodekX | Application Modernization Development
Advanced methodologies resolving dimensionality complications for autism neur...
Per capita expenditure prediction using model stacking based on satellite ima...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
NewMind AI Weekly Chronicles - August'25 Week I
Teaching material agriculture food technology
Network Security Unit 5.pdf for BCA BBA.

Ordina Accelerator program 2019 - Maven

  • 1. Titel Onderwerp Verantwoordelijke afdeing, personen. Datum JTech Accelerator Program 2019 CI-CD DevOps – Advanced Maven Bert Koorengevel - Java Software Engineer / CodeSmith, Ordina OSD - JTech @BertKoor
  • 3. 3 Apache Maven • Apache Software Foundation: community for Open Source software projects • Maven: a Yiddish word meaning “accumulator of knowledge” • Dominant build tool in the Java world • Multi-platform (Windows / Unix), command-line interface
  • 4. 4 • Making the build process easy • Providing a uniform build system • Providing quality project information • Providing guidelines for best practices development • Allowing transparent migration to new features Maven Objectives
  • 5. 5 Maven pom.xml • pom = Project Object Model • Controls the what and how of the build proces • What: groupId, artifactId, version, packaging : • jar = Java ARchive • war = Web application ARchive • ear = Java Enterprise ARchive • pom = other (produces only the pom.xml) or controlling multi-module builds • How: we’ll see later, controlled in principle by packaging and plugins • “Convention over Configuration” : sticking to the conventions reduces configuration • Convention: the pom.xml is located in the root folder of the project • Reference documentation: https://maven.apache.org/pom.html <?xml> <project> <modelVersion>4.0.0</modelVersion> <groupId>nl.ordina.jtech</groupId> <artifactId>MavenDemo</artifactId> <version>1.0</version> <packaging>jar</packaging> </project>
  • 6. 6 Maven Process Flow ‘Target’ folderMaven‘Source’ folder pom.xml Artifact
  • 8. 8
  • 9. 9
  • 10. 10 What is an Artifact? • General definition: “any object made by human beings” • In software: an application, module or component, typically archived (e.g. zip file) • Storage in a Repository • artifactId – identifier / name of the artefict • groupId – serves as Namespace, so the artifactId need not be worldwide unique • version – artifact versions are frozen. New build  increase version! • Path in repository: / groupId / artifactId / version / artifactId-version.ext SportsQuest/nl/ordina/jtech/sportsquest/ /1.2.3/SportsQuest-1.2.3.zip
  • 11. 11 Initializing a simple Maven Project  Execute: - mvn archetype:generate -DgroupId=nl.ordina -DartifactId=MyFirstPony • New projectfolder MyFirstPony is created, containing: • Standard folder structure with 2 java classes • A pom.xml
  • 12. 12  Visit https://github.com/IvoNet  Repo: javaee8-payara-microprofile-archetype  Generate your own project using this archetype  Study what is generated  Study the original pom.xml, how does it work? Exploring a custom archetype
  • 13. 13 Packaging • jar = Java ARchive • war = Web application ARchive • ear = Java Enterprise Archive • ejb = Enterprise Java Bean • pom = other (produces only the pom.xml) or controlling multi-module builds • maven-plugin • maven-archetype <?xml> <project> <modelVersion>4.0.0</modelVersion> <groupId>nl.ordina.jtech</groupId> <artifactId>MavenDemo</artifactId> <version>1.0</version> <packaging>jar</packaging> </project>
  • 14. 14  Simple as 1, 2, 3 … Artifact Versioning
  • 15. 15 Semantic Versioning : https://semver.org Version: 1 • Major version • Minor version • Patch version • Build number • or Qualifier .2.3-45 -SNAPSHOT
  • 16. 16 Maven Build Lifecycle 3 separate lifecycles:  Clean : discard previous built files (workspace)  Default : compilation & deployment (Maven repository)  Site : generation of html reports (code quality, etc)
  • 17. 17 Lifecycle Phases Each lifecycle consists of phases. Most important phases of the default lifecycle:  Compile  Test  Package  Validate  Install  Deploy
  • 18. 18 • clean ---------------------------------------------------------------------- | | /| / / |¯¯¯ | | /¯¯ ¯¯|¯¯ / |¯¯ ¯¯|¯¯ | | | / | /__ / |-- | | ¯¯ | /__ |--/ | | | | / | / / |___ | | __/ | / | | | ---------------------------------------------------------------------- [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building MavenDemo 0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo --- [INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget Convention: Maven only touches the “target” folder Slow-Motion …
  • 19. 19 • clean • validate • initialize • generate-sources • process-sources • generate-resources • process-resources ---------------------------------------------------------------------- | | /| / / |¯¯¯ | | /¯¯ ¯¯|¯¯ / |¯¯ ¯¯|¯¯ | | | / | /__ / |-- | | ¯¯ | /__ |--/ | | | | / | / / |___ | | __/ | / | | | ---------------------------------------------------------------------- [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building MavenDemo 0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo --- [INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource Conventions: Output goes to /target/classes Resource files are in /src/main/resources Slow-Motion …
  • 20. 20 • clean • validate • initialize • generate-sources • process-sources • generate-resources • process-resources • compile ---------------------------------------------------------------------- | | /| / / |¯¯¯ | | /¯¯ ¯¯|¯¯ / |¯¯ ¯¯|¯¯ | | | / | /__ / |-- | | ¯¯ | /__ |--/ | | | | / | / / |___ | | __/ | / | | | ---------------------------------------------------------------------- [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building MavenDemo 0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo --- [INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource ---------------------------------------------------------------------- [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building MavenDemo 0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo --- [INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargetclasses Convention: Java source files are in /src/main/java Slow-Motion …
  • 21. 21 • clean • validate • initialize • generate-sources • process-sources • generate-resources • process-resources • compile • process-classes • generate-test-sources • process-test-sources • generate-test-resources • process-test-resources ---------------------------------------------------------------------- [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building MavenDemo 0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo --- [INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargetclasses [INFO] ------------------------------------------------------------------------ [INFO] Building MavenDemo 0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo --- [INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargetclasses [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MavenDemo --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource Convention: Test output goes to /target/test-classes Test resources are in /src/test/resources Slow-Motion …
  • 22. 22 • clean • validate • initialize • generate-sources • process-sources • generate-resources • process-resources • compile • process-classes • generate-test-sources • process-test-sources • generate-test-resources • process-test-resources • test-compile [INFO] ------------------------------------------------------------------------ [INFO] Building MavenDemo 0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo --- [INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargetclasses [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MavenDemo --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo --- [INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargetclasses [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MavenDemo --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MavenDemo --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargettest-classes Convention: Test sources are in /src/test/java Slow-Motion …
  • 23. 23 • clean • validate • initialize • generate-sources • process-sources • generate-resources • process-resources • compile • process-classes • generate-test-sources • process-test-sources • generate-test-resources • process-test-resources • test-compile • process-test-classes • test [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo --- [INFO] Deleting C:WorkspaceMavenWorkshopMavenDemotarget [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargetclasses [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MavenDemo --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MavenDemo --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargettest-classes [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MavenDemo --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargettest-classes [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenDemo --- [INFO] Surefire report directory: C:WorkspaceMavenWorkshopMavenDemotargetsurefire- reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running HelloMavenTest Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec Results : Tests run: 4, Failures: 0, Errors: 0, Skipped: 0 Slow-Motion …
  • 24. 24 • clean • validate • initialize • generate-sources • process-sources • generate-resources • process-resources • compile • process-classes • generate-test-sources • process-test-sources • generate-test-resources • process-test-resources • test-compile • process-test-classes • test • prepare-package • package [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MavenDemo --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to C:WorkspaceMavenWorkshopMavenDemotargettest-classes [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenDemo --- [INFO] Surefire report directory: C:WorkspaceMavenWorkshopMavenDemotargetsurefire- reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running HelloMavenTest Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec Results : Tests run: 4, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenDemo --- [INFO] Surefire report directory: C:WorkspaceMavenWorkshopMavenDemotargetsurefire- reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running HelloMavenTest Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec Results : Tests run: 4, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MavenDemo --- [INFO] Building jar: C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar Slow-Motion …
  • 25. 25 • clean • validate • initialize • generate-sources • process-sources • generate-resources • process-resources • compile • process-classes • generate-test-sources • process-test-sources • generate-test-resources • process-test-resources • test-compile • process-test-classes • test • prepare-package • package • pre-integration-test • integration-test • post-integration-test • verify • install [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenDemo --- [INFO] Surefire report directory: C:WorkspaceMavenWorkshopMavenDemotargetsurefire- reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running HelloMavenTest Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec Results : Tests run: 4, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MavenDemo --- [INFO] Building jar: C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar T E S T S ------------------------------------------------------- Running HelloMavenTest Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec Results : Tests run: 4, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MavenDemo --- [INFO] Building jar: C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ MavenDemo --- [INFO] Installing C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar to C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.jar [INFO] Installing C:WorkspaceMavenWorkshopMavenDemopom.xml to C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.pom Tests run: 4, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MavenDemo --- [INFO] Building jar: C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ MavenDemo --- [INFO] Installing C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar to C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.jar [INFO] Installing C:WorkspaceMavenWorkshopMavenDemopom.xml to C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.028 s [INFO] Finished at: 2016-01-20T10:45:32+01:00 [INFO] Final Memory: 16M/159M [INFO] ------------------------------------------------------------------------ Slow-Motion …
  • 26. 26 • clean • validate • initialize • generate-sources • process-sources • generate-resources • process-resources • compile • process-classes • generate-test-sources • process-test-sources • generate-test-resources • process-test-resources • test-compile • process-test-classes • test • prepare-package • package • pre-integration-test • integration-test • post-integration-test • verify • install • deploy T E S T S ------------------------------------------------------- Running HelloMavenTest Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec Results : Tests run: 4, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MavenDemo --- [INFO] Building jar: C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ MavenDemo --- [INFO] Installing C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar to C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.jar [INFO] Installing C:WorkspaceMavenWorkshopMavenDemopom.xml to C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.pom [INFO] Installing C:WorkspaceMavenWorkshopMavenDemotargetMavenDemo-0.0.jar to C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.jar [INFO] Installing C:WorkspaceMavenWorkshopMavenDemopom.xml to C:MavenReponlbertkoorMavenDemo0.0MavenDemo-0.0.pom [INFO] [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ MavenDemo --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.232 s [INFO] Finished at: 2016-01-20T10:41:10+01:00 [INFO] Final Memory: 16M/157M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project MavenDemo: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in - DaltDeploymentRepository=id::layout::url parameter -> [Help 1] “mvn clean install” suffices“mvn clean package” suffices Slow-Motion …
  • 27. 27 Some Maven Conventions  Maven only touches the “target” folder  Locations: - Java sources: /src/main/java - Resources: /src/main/resources - Output: /target/classes - Test sources: /src/test/java - Test resources: /src/test/resources - Test output: /target/test-classes
  • 28. 28 Generic format:  mvn [ phase | pluginId:goal | -options ] ...  mvn [groupId:]pluginId[:version]:goal implicit groupId = org.apache.maven and maven-{pluginId}-plugin Some examples:  mvn –v  mvn archetype:generate -DartifactId=MyFirstPony  mvn package  mvn clean package  mvn help:effective-pom  mvn dependency:tree Maven Commandline
  • 29. 29 Properties <project> ... <description>My project ${myProperty}</description> <properties> <myProperty>has a value</myProperty> </properties> mvn [goals] –DmyProperty="has no value"
  • 30. 30 Modules – aggregate build  The Parent project containing the modules has packaging “pom”  Each module sits in its own subdirectory and is a separate Maven project that needs to be built <modules> <module>core</module> <module>model</module> <module>webservice</module> </modules>
  • 32. 32 Change the build (other plugin behaviour) based on activation:  Standard activation (activeByDefault)  Command line activation - parameter –PprofileName  Property values  JDK version  OS name, family, version  (in) Existance of a file Profiles
  • 33. 33  Just a dependency with Scope = import  Article by Edwin Derks: “to bom or not to bom” Importing a BOM pom with Dependency Management