SlideShare a Scribd company logo
Rabobank Ontwikkelprogramma
OPS Engineers
Bert Koorengevel – maart 2018
Building Java applications
with Apache Maven
https://karussell.wordpress.com/2009/09/29/
Staging
UFT
Continuous Integration
(build)
Continuous Delivery
(zero-touch deploy)
+
= CI-CD
Staging
Production
Apache Maven
• Apache Software Foundation:
community for Open Source software projects
• Maven: aYiddish word meaning
“accumulator of knowledge”
• Dominant build tool in the Java world
• Multi-platform (Windows / Unix),
command-line interface
Objectives
• 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 Installatie
• Prerequisites:
• JDK minimaal v1.7 (env.var %JAVA_HOME%)
• Download de .zip van https://maven.apache.org/download.cgi
• Eén distributie voor alle platforms (bevat zowel .bat als .sh scripts)
• Uitpakken naar bv c:appsmaven (nieuwe folder, full control)
• Voeg c:appsmavenbin toe aan je %PATH%
• Test op commandline:
• mvn -v
Extra configuratie voor RaboVDI’s
• Edit bestand [maven_home]confsettings.xml en pas het
<mirrors> gedeelte als volgt aan:
Maven is Modulair
• Alleen de core is nodig voor installatie (~2 Mb)
• Maven werkt verder (bijna) volledig met plugins
• Plugins en dependencies worden automatisch gedownload wanneer ze nodig zijn
• Deze afhankelijkheden worden in de user directory neergezet:
• ~/.m2 op linux / unix
• %HOMEPATH%/.m2 op windows
• Meerdere versies van plugins en dependencies kunnen naast elkaar bestaan
My First Maven project
• Execute:
• mvn archetype:generate -DgroupId=nl.ordina -DartifactId=MyFirstPony
• Plugins etc. worden gedownload
• Nieuwe projectfolder MyFirstPony
wordt gemaakt met daarin:
• Standaard folder structuur
met 2 java classes
• Een pom.xml
Maven process flow
‘Target’ folderMaven‘Source’ folder
pom.xml
WTF 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
What is an Artifact?
SportsQuestordina.nl.ordina.nl.ordina.jtech. -1.2.3nl.ordina.jtech.sportsquest./nl/ordina/jtech/sportsquest/ /1.2.3/SportsQuest-1.2.3.zip
Version: 1
• Major version
• Minor version
• Incremental version
• Build number
• or Qualifier
.2.3-45-SNAPSHOT
Structure of Maven artifactVersion
Local Maven Instance
Local Maven
Repository
Maven Repositories
get (artifact)
Artifact
Maven Central
Repository
get (artifact)
Artifact
Local Maven Instance
Local Maven
Repository
Maven Repositories
Maven Central
Repository
Corporate
Central
Repository
(Nexus)
Proxy
http://repo1.maven.org/maven2/http://maven.rabobank.nl/nexus
Firewall
Build Server
BuildServer
Repository
(Artifactory)
https://lrv142za/artifactory/C:MavenRepo
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
<?xml>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>nl.ordina.jtech</groupId>
<artifactId>MavenDemo</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
</project>
3 separate lifecycles:
• Clean : discard previous built files (workspace)
• Default : compilation & deployment (Maven repository)
• Site : generation of html reports (code quality, etc)
Maven Build Lifecycle
Each lifecycle consists of phases.
Most important phases of the default lifecycle:
• Compile
• Test
• Package
• Validate
• Install
• Deploy
Maven Build Lifecycle Phases
My First Maven Project Build
• Execute:
• cd MyFirstPony
• mvn install
• mvn package
• mvn clean package
En zoek de verschillen…
• 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 …
• 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 …
• 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 …
• 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 …
• 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 …
• 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 …
• 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 …
• 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 …
• 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 …
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
Maven commandline
Tot nu toe gezien:
• mvn –v
• mvn archetype:generate -DartifactId=MyFirstPony
• mvn package
• mvn clean package
Algemeen formaat:
• mvn [ phase | pluginId:goal | -options ] ...
• mvn [groupId:]pluginId[:version]:goal
impliciet groupId org.apache.maven en maven-{pluginId}-plugin
Maven Build Failures
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[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]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
c:WorkspaceMavenWorkshopMavenDemo> _
• mvn […] -e
Maven Build Failures
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[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]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
c:WorkspaceMavenWorkshopMavenDemo> _
[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]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-
plugin:2.7:deploy (default-deploy) on project MavenDemo: Deploy
ment failed: repository element was not specified in the POM inside distributionManagement element or in -
DaltDeploymentRepository=id::layout::url parameter
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Deployment failed: repository element was not specified in the POM
inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
at org.apache.maven.plugin.deploy.DeployMojo.getDeploymentRepository(DeployMojo.java:235)
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:118)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
• mvn […] -e
• mvn […] -X
Maven Build Failures
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[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]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
c:WorkspaceMavenWorkshopMavenDemo> _
[INFO] Scanning for projects...
[DEBUG] Extension realms for project nl.bertkoor:MavenDemo:jar:0.0: (none)
[DEBUG] Looking up lifecyle mappings for packaging jar from ClassRealm[plexus.core, parent: null]
[DEBUG] === REACTOR BUILD PLAN ================================================
[DEBUG] Project: nl.bertkoor:MavenDemo:jar:0.0
[DEBUG] Tasks: [validate]
[DEBUG] Style: Regular
[DEBUG] =======================================================================
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenDemo 0.0
[INFO] ------------------------------------------------------------------------
[DEBUG] Lifecycle default -> [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]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[DEBUG] Lifecycle default -> [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]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[DEBUG] === PROJECT BUILD PLAN ================================================
[DEBUG] Project: nl.bertkoor:MavenDemo:0.0
[DEBUG] Dependencies (collect): []
[DEBUG] Dependencies (resolve): [test]
[DEBUG] Repositories (dependencies): [central (https://lrv142za.europe.intranet/artifactory/libs-release, default, releases)]
[DEBUG] Repositories (plugins) : [central (https://lrv142za.europe.intranet/artifactory/plugins-release, default, releases)]
[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal: org.apache.maven.plugins:maven-antrun-plugin:1.6:run (default)
[DEBUG] Style: Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<localRepository>${localRepository}</localRepository>
<pluginArtifacts>${plugin.artifacts}</pluginArtifacts>
<project>${project}</project>
<sourceRoot>${sourceRoot}</sourceRoot>
<target name="ant-step01">
<echo>Hello Maven!</echo>
</target>
<testSourceRoot>${testSourceRoot}</testSourceRoot>
<versionsPropertyName default-value="maven.project.dependencies.versions"/>
</configuration>
• mvn […] -e
• mvn […] -X
• http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Maven Build Failures
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[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]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
c:WorkspaceMavenWorkshopMavenDemo> _
Maven Build Failures
• mvn […] -e
• mvn […] -X
• http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
• Read the error message!
Maven Build Failures
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[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]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
c:WorkspaceMavenWorkshopMavenDemo> _
My pom.xml:
Mystery…
<?xml>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>nl.ordina.jtech</groupId>
<artifactId>MavenDemo</artifactId>
<version>0.0</version>
</project>
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenDemo 0.0
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo ---
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo ---
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo ---
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenDemo ---
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MavenDemo ---
[INFO] --- maven-install-plugin:2.4:install (default-install) @ MavenDemo ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Maven did:
<?xml>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>nl.ordina.jtech</groupId>
<artifactId>MavenDemo</artifactId>
<version>0.0</version>
</project>
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenDemo 0.0
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo ---
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo ---
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo ---
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenDemo ---
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MavenDemo ---
[INFO] --- maven-install-plugin:2.4:install (default-install) @ MavenDemo ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Convention over configuration : “Super” pom
mvn help:effective-pom
Demystified: the ‘Effective’ pom
My pom.xml:
Maven did:
POM elements
• GroupId
• ArtifactId
• Version
• Packaging
• Name
• Description
• Mailinglists
• Developers
• SCM
• Modules
• Dependencies
• Build
• Plugins
• Properties
• Repositories
• CI Management
• Reports
• DistributionManagement
• IssueManagement
Packaging
• jar (default)
• war
• ejb
• ear
• pom
• maven-plugin
De packaging bepaalt welke phases er worden gebruikt en welke
standaard set van plugin goals er aan de phases gekoppeld zijn
Packaging experiment
• Voer uit in het MyLittlePony project
• mvn help:effective-pom –Doutput=eff_pom_jar.xml
• Verander de packaging in war
• Voer uit:
• mvn help:effective-pom –Doutput=eff_pom_war.xml
• Vergelijk de twee output bestanden
Properties
<project>
...
<description>My project ${myProperty}</description>
<properties>
<myProperty>has a value</myProperty>
</properties>
mvn [goals] –DmyProperty="has no value"
Dependencies
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
• Vastleggen van afhankelijkheden
met andere jars
• Scope is optioneel:
• compile (default)
• provided
• test
Transitive Dependencies
• MyProject dependencies:
• LibraryA-1.1.jar, which depends on
• LibraryB-1.1.jar
• LibraryC-1.4.jar, which depends on
• LibraryB-1.4.jar
• Inzichtelijk te maken met:
• mvn dependency:tree
• Op te lossen met <exclude>
DependencyManagement
<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>
• Declaratie van versie zonder de
afhankelijkheid vast te leggen
• Meestal in Parent pom’s,
uniformiteit over gehele project
Modules – aggregate build
• Elke module is een subdirectory
(kan afwijkend artifactId hebben)
met een eigen Maven project dat
ook moet worden gebouwd
• Parent die de modules bevat
heeft meestal packaging=pom
<modules>
<module>core</module>
<module>model</module>
<module>webservice</module>
</modules>
Plugins
• Toevoegen of aanpassen van gedrag
• Vaak ook via PluginManagement in de parent pom
Parent pom
• Bovenliggende folder
• Relative Path
• GroupId, artifactId & version (coordinaten)
c:MavenReponlbertkoorMavenDemo0.0> java -cp MavenDemo-0.0.jar HelloMaven
Hello Maven!
c:MavenReponlbertkoorMavenDemo0.0> java -cp MavenDemo-0.0.jar HelloMaven Bert
Hello Bert!
c:MavenReponlbertkoorMavenDemo0.0> java -jar MavenDemo-0.0.jar
no main manifest attribute, in MavenDemo-0.0.jar
c:MavenReponlbertkoorMavenDemo0.0> java -cp MavenDemo-0.0.jar HelloMaven
Hello Maven!
c:MavenReponlbertkoorMavenDemo0.0> java -cp MavenDemo-0.0.jar HelloMaven Bert
Hello Bert!
c:MavenReponlbertkoorMavenDemo0.0> java -jar MavenDemo-0.0.jar
no main manifest attribute, in MavenDemo-0.0.jar
C:WorkspaceMavenWorkshopMavenDemo> mvn clean install
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
c:MavenReponlbertkoorMavenDemo0.0> java -jar MavenDemo-0.0.jar
Hello Maven!
• maven-compiler-plugin
• maven-jar-plugin
• maven-resources-plugin
• maven-assembly-plugin
Meer info: https://maven.apache.org/plugins/index.html
Meest gebruikte plugins
Resources
• Folders src/main/resources en src/test/resources
• Onderliggende directory structuur wordt in .jar geplaatst
• maven-resources-plugin configuratie (o.a.)
• includes
• excludes
• Resource Filtering:
• Vervangt ${property} met z’n waarde
Profielen
Aanpassing van de build (ander plugin gedrag) op basis van activering:
• Standaard activering (activeByDefault)
• Command line activering
• parameter –PprofileName
• Property waarden
• JDK versie
• OS naam, familie, versie
• (niet) Bestaan van een bestand
Profiel definities
• In de pom.xml
• In de profiles.xml
• In de persoonlijke settings.xml
• In de maven config
• %MAVEN_HOME%/conf/settings.xml
Settings.xml
Locatie:
• %MavenHome%/conf/settings.xml
• %UserHome%/.m2/settings.xml
• In de project folder
Bevat:
• Repository locaties
• Proxy instellingen
• Mirrors
• Server access credentials
• Zie https://github.com/BertKoor/OefenMaven
In het diepe !!!

More Related Content

What's hot

Apache Maven
Apache MavenApache Maven
Apache Maven
Rahul Tanwani
 
Maven
Maven Maven
Maven
Khan625
 
Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
Mike Desjardins
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by Example
Hsi-Kai Wang
 
Maven 2 features
Maven 2 featuresMaven 2 features
Maven 2 features
Angel Ruiz
 
Maven Overview
Maven OverviewMaven Overview
Maven Overview
FastConnect
 
Maven 3 Overview
Maven 3  OverviewMaven 3  Overview
Maven 3 Overview
Mike Ensor
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1
MD Sayem Ahmed
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to Maven
Joao Pereira
 
Maven tutorial
Maven tutorialMaven tutorial
Maven tutorial
Dragos Balan
 
Maven 2 Introduction
Maven 2 IntroductionMaven 2 Introduction
Maven 2 Introduction
Valentin Jacquemin
 
Maven tutorial
Maven tutorialMaven tutorial
Maven tutorial
James Cellini
 
Maven
MavenMaven
Maven ppt
Maven pptMaven ppt
Maven ppt
natashasweety7
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to Maven
Vadym Lotar
 
Introduction to Apache Maven
Introduction to Apache MavenIntroduction to Apache Maven
Introduction to Apache Maven
Rajind Ruparathna
 
Maven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafeMaven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafe
Holasz Kati
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
Onkar Deshpande
 
Apache Maven In 10 Slides
Apache Maven In 10 SlidesApache Maven In 10 Slides
Apache Maven In 10 Slides
Robert Burrell Donkin
 
Log management (elk) for spring boot application
Log management (elk) for spring boot applicationLog management (elk) for spring boot application
Log management (elk) for spring boot application
Vadym Lotar
 

What's hot (20)

Apache Maven
Apache MavenApache Maven
Apache Maven
 
Maven
Maven Maven
Maven
 
Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by Example
 
Maven 2 features
Maven 2 featuresMaven 2 features
Maven 2 features
 
Maven Overview
Maven OverviewMaven Overview
Maven Overview
 
Maven 3 Overview
Maven 3  OverviewMaven 3  Overview
Maven 3 Overview
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to Maven
 
Maven tutorial
Maven tutorialMaven tutorial
Maven tutorial
 
Maven 2 Introduction
Maven 2 IntroductionMaven 2 Introduction
Maven 2 Introduction
 
Maven tutorial
Maven tutorialMaven tutorial
Maven tutorial
 
Maven
MavenMaven
Maven
 
Maven ppt
Maven pptMaven ppt
Maven ppt
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to Maven
 
Introduction to Apache Maven
Introduction to Apache MavenIntroduction to Apache Maven
Introduction to Apache Maven
 
Maven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafeMaven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafe
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
Apache Maven In 10 Slides
Apache Maven In 10 SlidesApache Maven In 10 Slides
Apache Maven In 10 Slides
 
Log management (elk) for spring boot application
Log management (elk) for spring boot applicationLog management (elk) for spring boot application
Log management (elk) for spring boot application
 

Similar to Development Tools - Maven

Ordina Accelerator program 2019 - Maven
Ordina Accelerator program 2019 - MavenOrdina Accelerator program 2019 - Maven
Ordina Accelerator program 2019 - Maven
Bert Koorengevel
 
Joget Workflow v6 Training Slides - 16 - Preparing Development Environment
Joget Workflow v6 Training Slides - 16 - Preparing Development EnvironmentJoget Workflow v6 Training Slides - 16 - Preparing Development Environment
Joget Workflow v6 Training Slides - 16 - Preparing Development Environment
Joget Workflow
 
Using Maven2
Using Maven2Using Maven2
Using Maven2
elliando dias
 
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...
Joget Workflow
 
Agentless System Crawler - InterConnect 2016
Agentless System Crawler - InterConnect 2016Agentless System Crawler - InterConnect 2016
Agentless System Crawler - InterConnect 2016
Canturk Isci
 
Caching with Varnish
Caching with VarnishCaching with Varnish
Caching with Varnish
schoefmax
 
Towards Continuous Deployment with Django
Towards Continuous Deployment with DjangoTowards Continuous Deployment with Django
Towards Continuous Deployment with Django
Roger Barnes
 
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 HowtoPostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
Mark Wong
 
Websphere
WebsphereWebsphere
Websphere
TRAINING ICON
 
Mark Collier Keynote - OpenStack Day London June 2014
Mark Collier Keynote -  OpenStack Day London June 2014Mark Collier Keynote -  OpenStack Day London June 2014
Mark Collier Keynote - OpenStack Day London June 2014
OpenStack Foundation
 
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
London Microservices
 
Scripting for infosecs
Scripting for infosecsScripting for infosecs
Scripting for infosecs
nancysuemartin
 
20160221 va interconnect_pub
20160221 va interconnect_pub20160221 va interconnect_pub
20160221 va interconnect_pub
Canturk Isci
 
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptxCoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
Hervé Boutemy
 
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
DECK36
 
20180607 master your vms with vagrant
20180607 master your vms with vagrant20180607 master your vms with vagrant
20180607 master your vms with vagrant
makker_nl
 
Cadence flow
Cadence flowCadence flow
Cadence flow
thanhbinh12x
 
3 Ways To UP Your OPs Game
3 Ways To UP Your OPs Game3 Ways To UP Your OPs Game
3 Ways To UP Your OPs Game
David Tesar
 
Gradle como alternativa a maven
Gradle como alternativa a mavenGradle como alternativa a maven
Gradle como alternativa a maven
David Gómez García
 
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
Amazon Web Services
 

Similar to Development Tools - Maven (20)

Ordina Accelerator program 2019 - Maven
Ordina Accelerator program 2019 - MavenOrdina Accelerator program 2019 - Maven
Ordina Accelerator program 2019 - Maven
 
Joget Workflow v6 Training Slides - 16 - Preparing Development Environment
Joget Workflow v6 Training Slides - 16 - Preparing Development EnvironmentJoget Workflow v6 Training Slides - 16 - Preparing Development Environment
Joget Workflow v6 Training Slides - 16 - Preparing Development Environment
 
Using Maven2
Using Maven2Using Maven2
Using Maven2
 
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...
 
Agentless System Crawler - InterConnect 2016
Agentless System Crawler - InterConnect 2016Agentless System Crawler - InterConnect 2016
Agentless System Crawler - InterConnect 2016
 
Caching with Varnish
Caching with VarnishCaching with Varnish
Caching with Varnish
 
Towards Continuous Deployment with Django
Towards Continuous Deployment with DjangoTowards Continuous Deployment with Django
Towards Continuous Deployment with Django
 
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 HowtoPostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
 
Websphere
WebsphereWebsphere
Websphere
 
Mark Collier Keynote - OpenStack Day London June 2014
Mark Collier Keynote -  OpenStack Day London June 2014Mark Collier Keynote -  OpenStack Day London June 2014
Mark Collier Keynote - OpenStack Day London June 2014
 
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
 
Scripting for infosecs
Scripting for infosecsScripting for infosecs
Scripting for infosecs
 
20160221 va interconnect_pub
20160221 va interconnect_pub20160221 va interconnect_pub
20160221 va interconnect_pub
 
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptxCoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
 
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
 
20180607 master your vms with vagrant
20180607 master your vms with vagrant20180607 master your vms with vagrant
20180607 master your vms with vagrant
 
Cadence flow
Cadence flowCadence flow
Cadence flow
 
3 Ways To UP Your OPs Game
3 Ways To UP Your OPs Game3 Ways To UP Your OPs Game
3 Ways To UP Your OPs Game
 
Gradle como alternativa a maven
Gradle como alternativa a mavenGradle como alternativa a maven
Gradle como alternativa a maven
 
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
 

More from Bert Koorengevel

Ordina Accelerator program 2019 - Jenkins blue ocean pipelines
Ordina Accelerator program 2019 - Jenkins blue ocean pipelinesOrdina Accelerator program 2019 - Jenkins blue ocean pipelines
Ordina Accelerator program 2019 - Jenkins blue ocean pipelines
Bert Koorengevel
 
Ordina Accelerator program 2019 - Quality assurance
Ordina Accelerator program 2019 - Quality assuranceOrdina Accelerator program 2019 - Quality assurance
Ordina Accelerator program 2019 - Quality assurance
Bert Koorengevel
 
Ordina Accelerator program 2019 - Linux
Ordina Accelerator program 2019 - LinuxOrdina Accelerator program 2019 - Linux
Ordina Accelerator program 2019 - Linux
Bert Koorengevel
 
Ordina Accelerator program 2019 - DevOps CI-CD
Ordina Accelerator program 2019 - DevOps CI-CDOrdina Accelerator program 2019 - DevOps CI-CD
Ordina Accelerator program 2019 - DevOps CI-CD
Bert Koorengevel
 
Development Tools - Git SCM
Development Tools - Git SCMDevelopment Tools - Git SCM
Development Tools - Git SCM
Bert Koorengevel
 
Brain bit camel
Brain bit camelBrain bit camel
Brain bit camel
Bert Koorengevel
 

More from Bert Koorengevel (6)

Ordina Accelerator program 2019 - Jenkins blue ocean pipelines
Ordina Accelerator program 2019 - Jenkins blue ocean pipelinesOrdina Accelerator program 2019 - Jenkins blue ocean pipelines
Ordina Accelerator program 2019 - Jenkins blue ocean pipelines
 
Ordina Accelerator program 2019 - Quality assurance
Ordina Accelerator program 2019 - Quality assuranceOrdina Accelerator program 2019 - Quality assurance
Ordina Accelerator program 2019 - Quality assurance
 
Ordina Accelerator program 2019 - Linux
Ordina Accelerator program 2019 - LinuxOrdina Accelerator program 2019 - Linux
Ordina Accelerator program 2019 - Linux
 
Ordina Accelerator program 2019 - DevOps CI-CD
Ordina Accelerator program 2019 - DevOps CI-CDOrdina Accelerator program 2019 - DevOps CI-CD
Ordina Accelerator program 2019 - DevOps CI-CD
 
Development Tools - Git SCM
Development Tools - Git SCMDevelopment Tools - Git SCM
Development Tools - Git SCM
 
Brain bit camel
Brain bit camelBrain bit camel
Brain bit camel
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 

Development Tools - Maven

  • 1. Rabobank Ontwikkelprogramma OPS Engineers Bert Koorengevel – maart 2018 Building Java applications with Apache Maven
  • 4. Apache Maven • Apache Software Foundation: community for Open Source software projects • Maven: aYiddish word meaning “accumulator of knowledge” • Dominant build tool in the Java world • Multi-platform (Windows / Unix), command-line interface
  • 5. Objectives • 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
  • 6. Maven Installatie • Prerequisites: • JDK minimaal v1.7 (env.var %JAVA_HOME%) • Download de .zip van https://maven.apache.org/download.cgi • Eén distributie voor alle platforms (bevat zowel .bat als .sh scripts) • Uitpakken naar bv c:appsmaven (nieuwe folder, full control) • Voeg c:appsmavenbin toe aan je %PATH% • Test op commandline: • mvn -v
  • 7. Extra configuratie voor RaboVDI’s • Edit bestand [maven_home]confsettings.xml en pas het <mirrors> gedeelte als volgt aan:
  • 8. Maven is Modulair • Alleen de core is nodig voor installatie (~2 Mb) • Maven werkt verder (bijna) volledig met plugins • Plugins en dependencies worden automatisch gedownload wanneer ze nodig zijn • Deze afhankelijkheden worden in de user directory neergezet: • ~/.m2 op linux / unix • %HOMEPATH%/.m2 op windows • Meerdere versies van plugins en dependencies kunnen naast elkaar bestaan
  • 9. My First Maven project • Execute: • mvn archetype:generate -DgroupId=nl.ordina -DartifactId=MyFirstPony • Plugins etc. worden gedownload • Nieuwe projectfolder MyFirstPony wordt gemaakt met daarin: • Standaard folder structuur met 2 java classes • Een pom.xml
  • 10. Maven process flow ‘Target’ folderMaven‘Source’ folder pom.xml
  • 12.
  • 13.
  • 14. • 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 What is an Artifact? SportsQuestordina.nl.ordina.nl.ordina.jtech. -1.2.3nl.ordina.jtech.sportsquest./nl/ordina/jtech/sportsquest/ /1.2.3/SportsQuest-1.2.3.zip
  • 15. Version: 1 • Major version • Minor version • Incremental version • Build number • or Qualifier .2.3-45-SNAPSHOT Structure of Maven artifactVersion
  • 16. Local Maven Instance Local Maven Repository Maven Repositories get (artifact) Artifact Maven Central Repository get (artifact) Artifact
  • 17. Local Maven Instance Local Maven Repository Maven Repositories Maven Central Repository Corporate Central Repository (Nexus) Proxy http://repo1.maven.org/maven2/http://maven.rabobank.nl/nexus Firewall Build Server BuildServer Repository (Artifactory) https://lrv142za/artifactory/C:MavenRepo
  • 18. 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 <?xml> <project> <modelVersion>4.0.0</modelVersion> <groupId>nl.ordina.jtech</groupId> <artifactId>MavenDemo</artifactId> <version>1.0</version> <packaging>jar</packaging> </project>
  • 19. 3 separate lifecycles: • Clean : discard previous built files (workspace) • Default : compilation & deployment (Maven repository) • Site : generation of html reports (code quality, etc) Maven Build Lifecycle
  • 20. Each lifecycle consists of phases. Most important phases of the default lifecycle: • Compile • Test • Package • Validate • Install • Deploy Maven Build Lifecycle Phases
  • 21. My First Maven Project Build • Execute: • cd MyFirstPony • mvn install • mvn package • mvn clean package En zoek de verschillen…
  • 22. • 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 …
  • 23. • 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 …
  • 24. • 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 …
  • 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 ---------------------------------------------------------------------- [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 …
  • 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 [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 …
  • 27. • 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 …
  • 28. • 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 …
  • 29. • 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 …
  • 30. • 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 …
  • 31. 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
  • 32. Maven commandline Tot nu toe gezien: • mvn –v • mvn archetype:generate -DartifactId=MyFirstPony • mvn package • mvn clean package Algemeen formaat: • mvn [ phase | pluginId:goal | -options ] ... • mvn [groupId:]pluginId[:version]:goal impliciet groupId org.apache.maven en maven-{pluginId}-plugin
  • 33. Maven Build Failures [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [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] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException c:WorkspaceMavenWorkshopMavenDemo> _
  • 34. • mvn […] -e Maven Build Failures [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [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] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException c:WorkspaceMavenWorkshopMavenDemo> _ [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] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy- plugin:2.7:deploy (default-deploy) on project MavenDemo: Deploy ment failed: repository element was not specified in the POM inside distributionManagement element or in - DaltDeploymentRepository=id::layout::url parameter at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.MojoExecutionException: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter at org.apache.maven.plugin.deploy.DeployMojo.getDeploymentRepository(DeployMojo.java:235) at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:118) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 20 more
  • 35. • mvn […] -e • mvn […] -X Maven Build Failures [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [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] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException c:WorkspaceMavenWorkshopMavenDemo> _ [INFO] Scanning for projects... [DEBUG] Extension realms for project nl.bertkoor:MavenDemo:jar:0.0: (none) [DEBUG] Looking up lifecyle mappings for packaging jar from ClassRealm[plexus.core, parent: null] [DEBUG] === REACTOR BUILD PLAN ================================================ [DEBUG] Project: nl.bertkoor:MavenDemo:jar:0.0 [DEBUG] Tasks: [validate] [DEBUG] Style: Regular [DEBUG] ======================================================================= [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building MavenDemo 0.0 [INFO] ------------------------------------------------------------------------ [DEBUG] Lifecycle default -> [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] [DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean] [DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy] [DEBUG] Lifecycle default -> [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] [DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean] [DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy] [DEBUG] === PROJECT BUILD PLAN ================================================ [DEBUG] Project: nl.bertkoor:MavenDemo:0.0 [DEBUG] Dependencies (collect): [] [DEBUG] Dependencies (resolve): [test] [DEBUG] Repositories (dependencies): [central (https://lrv142za.europe.intranet/artifactory/libs-release, default, releases)] [DEBUG] Repositories (plugins) : [central (https://lrv142za.europe.intranet/artifactory/plugins-release, default, releases)] [DEBUG] ----------------------------------------------------------------------- [DEBUG] Goal: org.apache.maven.plugins:maven-antrun-plugin:1.6:run (default) [DEBUG] Style: Regular [DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?> <configuration> <localRepository>${localRepository}</localRepository> <pluginArtifacts>${plugin.artifacts}</pluginArtifacts> <project>${project}</project> <sourceRoot>${sourceRoot}</sourceRoot> <target name="ant-step01"> <echo>Hello Maven!</echo> </target> <testSourceRoot>${testSourceRoot}</testSourceRoot> <versionsPropertyName default-value="maven.project.dependencies.versions"/> </configuration>
  • 36. • mvn […] -e • mvn […] -X • http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException Maven Build Failures [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [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] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException c:WorkspaceMavenWorkshopMavenDemo> _
  • 38. • mvn […] -e • mvn […] -X • http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException • Read the error message! Maven Build Failures [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [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] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException c:WorkspaceMavenWorkshopMavenDemo> _
  • 39. My pom.xml: Mystery… <?xml> <project> <modelVersion>4.0.0</modelVersion> <groupId>nl.ordina.jtech</groupId> <artifactId>MavenDemo</artifactId> <version>0.0</version> </project> [INFO] ------------------------------------------------------------------------ [INFO] Building MavenDemo 0.0 [INFO] ------------------------------------------------------------------------ [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo --- [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo --- [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo --- [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenDemo --- [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MavenDemo --- [INFO] --- maven-install-plugin:2.4:install (default-install) @ MavenDemo --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ Maven did:
  • 40. <?xml> <project> <modelVersion>4.0.0</modelVersion> <groupId>nl.ordina.jtech</groupId> <artifactId>MavenDemo</artifactId> <version>0.0</version> </project> [INFO] ------------------------------------------------------------------------ [INFO] Building MavenDemo 0.0 [INFO] ------------------------------------------------------------------------ [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenDemo --- [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenDemo --- [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenDemo --- [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenDemo --- [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MavenDemo --- [INFO] --- maven-install-plugin:2.4:install (default-install) @ MavenDemo --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ Convention over configuration : “Super” pom mvn help:effective-pom Demystified: the ‘Effective’ pom My pom.xml: Maven did:
  • 41. POM elements • GroupId • ArtifactId • Version • Packaging • Name • Description • Mailinglists • Developers • SCM • Modules • Dependencies • Build • Plugins • Properties • Repositories • CI Management • Reports • DistributionManagement • IssueManagement
  • 42. Packaging • jar (default) • war • ejb • ear • pom • maven-plugin De packaging bepaalt welke phases er worden gebruikt en welke standaard set van plugin goals er aan de phases gekoppeld zijn
  • 43. Packaging experiment • Voer uit in het MyLittlePony project • mvn help:effective-pom –Doutput=eff_pom_jar.xml • Verander de packaging in war • Voer uit: • mvn help:effective-pom –Doutput=eff_pom_war.xml • Vergelijk de twee output bestanden
  • 44. Properties <project> ... <description>My project ${myProperty}</description> <properties> <myProperty>has a value</myProperty> </properties> mvn [goals] –DmyProperty="has no value"
  • 46. Transitive Dependencies • MyProject dependencies: • LibraryA-1.1.jar, which depends on • LibraryB-1.1.jar • LibraryC-1.4.jar, which depends on • LibraryB-1.4.jar • Inzichtelijk te maken met: • mvn dependency:tree • Op te lossen met <exclude>
  • 48. Modules – aggregate build • Elke module is een subdirectory (kan afwijkend artifactId hebben) met een eigen Maven project dat ook moet worden gebouwd • Parent die de modules bevat heeft meestal packaging=pom <modules> <module>core</module> <module>model</module> <module>webservice</module> </modules>
  • 49. Plugins • Toevoegen of aanpassen van gedrag • Vaak ook via PluginManagement in de parent pom Parent pom • Bovenliggende folder • Relative Path • GroupId, artifactId & version (coordinaten)
  • 50. c:MavenReponlbertkoorMavenDemo0.0> java -cp MavenDemo-0.0.jar HelloMaven Hello Maven! c:MavenReponlbertkoorMavenDemo0.0> java -cp MavenDemo-0.0.jar HelloMaven Bert Hello Bert! c:MavenReponlbertkoorMavenDemo0.0> java -jar MavenDemo-0.0.jar no main manifest attribute, in MavenDemo-0.0.jar
  • 51. c:MavenReponlbertkoorMavenDemo0.0> java -cp MavenDemo-0.0.jar HelloMaven Hello Maven! c:MavenReponlbertkoorMavenDemo0.0> java -cp MavenDemo-0.0.jar HelloMaven Bert Hello Bert! c:MavenReponlbertkoorMavenDemo0.0> java -jar MavenDemo-0.0.jar no main manifest attribute, in MavenDemo-0.0.jar C:WorkspaceMavenWorkshopMavenDemo> mvn clean install [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ c:MavenReponlbertkoorMavenDemo0.0> java -jar MavenDemo-0.0.jar Hello Maven!
  • 52. • maven-compiler-plugin • maven-jar-plugin • maven-resources-plugin • maven-assembly-plugin Meer info: https://maven.apache.org/plugins/index.html Meest gebruikte plugins
  • 53. Resources • Folders src/main/resources en src/test/resources • Onderliggende directory structuur wordt in .jar geplaatst • maven-resources-plugin configuratie (o.a.) • includes • excludes • Resource Filtering: • Vervangt ${property} met z’n waarde
  • 54. Profielen Aanpassing van de build (ander plugin gedrag) op basis van activering: • Standaard activering (activeByDefault) • Command line activering • parameter –PprofileName • Property waarden • JDK versie • OS naam, familie, versie • (niet) Bestaan van een bestand
  • 55. Profiel definities • In de pom.xml • In de profiles.xml • In de persoonlijke settings.xml • In de maven config • %MAVEN_HOME%/conf/settings.xml
  • 56. Settings.xml Locatie: • %MavenHome%/conf/settings.xml • %UserHome%/.m2/settings.xml • In de project folder Bevat: • Repository locaties • Proxy instellingen • Mirrors • Server access credentials