SlideShare a Scribd company logo
1 of 19
Download to read offline
Maven overview
Samuel Langlois – May 2017
Apache Maven history
• Started by Jason Van Zyl in 2001
o Standardising the build of Apache Turbine
• Version history
o 1.0 in Jul-2004, after loads of betas
o 2.0 in Oct-2005, completely redesigned
o 3.0 in Oct-2010, fully compatible
o 3.5.0 is the latest, released Apr-2017
• Previsouly somewhat controlled by Sonatype
• Strong and stable!
Maven is *not* a better Ant
<project>
<target name="compile">
<javac ...>
</target>
<target name="test">
<junit ..>
</target>
<target name="package">
<jar ..>
</target>
</project>
<project>
<groupId>org.alfresco</>
<artifactId>alfresco-core</>
<version>5.1.0</>
<name>Alfresco Core</>
<dependencies>
<dependency>
<groupId>commons-logging</>
<artifactId>commons-logging</>
<version>1.1</>
</dependency>
</dependencies>
</project>
build.xml pom.xml
Maven is *not* a better Ant
<project>
<target name="compile">
<javac ...>
</target>
<target name="test">
<junit ..>
</target>
<target name="package">
<jar ..>
</target>
</project>
build.xml pom.xml
CODE
<project>
<groupId>org.alfresco</>
<artifactId>alfresco-core</>
<version>5.1.0</>
<name>Alfresco Core</>
<dependencies>
<dependency>
<groupId>commons-logging</>
<artifactId>commons-logging</>
<version>1.1</>
</dependency>
</dependencies>
</project>
DATA
Maven plugins
• Written in Java (MOJO), or ...
• Entry-points are called goals
• Examples:
o Core
 maven-compiler-plugin
 maven-resources-plugin - including filtering
 maven-surefire-plugin - executes tests
o Reporting
 maven-javadoc-plugin
 maven-findbugs-plugin
o Code Generation
 antlr3-maven-plugin
o maven-alfresco-plugin !!
o .......
Configuring a plug-in
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<debug>false</debug>
</configuration>
</plugin>
Maven phases
Phase Default binding for jar packaging
initialize
generate-sources
process-resources resources:resources
compile compiler:compile
generate-test-sources
process-test-resources resources:testResources
test-compile compiler:testCompile
test surefire:test
package jar:jar
pre-integration-test
integration-test
post-integration-test
install install:install
deploy deploy:deploy
Plugging a plug-in
<plugin>
<artifactId>maven-jetty-plugin</artifactId>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals> <goal>run</goal> </goals>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals> <goal>stop</goal> </goals>
</execution>
</executions>
<configuration>
<port>9876</port>
</configuration>
</plugin>
Maven conventions
• tree layout
o pom.xml
o src
 main
• java
• resources
 test
• java
• resources
o target
• tests are executed as part of the build
Follow the Maven way!
Maven dependency
A dependency (internal or external) is made of:
• mandatory : GAV
o groupId (org.alfresco)
o artifactId (alfresco-datamodel)
o version
 release: 4.1.0
 snapshot: 4.1.0-SNAPSHOT
• optionally:
o scope (compile, test, provided, ...)
o classifier (jdk6, sources, javadocs, ...)
Dependencies are transitive!
• mvn dependency:tree dependency:list
Maven dependency management
mvnlocal Maven repo
~/.m2/repository
Maven Central
http://repo.maven.apache.org/maven2/
mvn install
Maven dependency management
mvnmvn install
Team Repo
Maven Central
http://repo.maven.apache.org/maven2/
local Maven repo
~/.m2/repository
Invoking Maven
• call a phase
o mvn clean install
o mvn test
• call a goal
o mvn surefire:test
o mvn javadoc:javadoc
• Useful switches
o -o : offline
o -U : force check for snapshot updates
o -X : verbose, to check plugin configuration
• Adding command-line params for plugins
o -DskipTests
o -Dtest=MyClassTest
Multimodule builds
• call sub-projects in parent folder
<packaging>pom</packaging>
<modules>
<module>core</module>
<module>web-client</module>
</modules>
• pom inheritance in sub-projects
<parent>
<groupId>...
<artifactId>...
<version>...
</parent>
• Computing the actual pom
mvn help:effective-pom
Maven profiles
• conditional parts in the pom.xml
o plug/unplug a submodule
o run a different set of tests
o test various platforms
o ...
• Triggering a profile
o command line: -Pprofile1,!profile3
o presence/absence of a property
o automatic: JDK, OS, platform, existence of a file, …
IDE integration
• "Old school": Maven generating IDE project
o mvn eclipse:eclipse [-DdownloadSources=true]
o mvn idea:idea
o mvn netbeans:netbeans
• Recommended: IDE directly reading pom.xml
o m2e plugin, included in "Eclipse IDE for Java Devs"
Reporting - Maven site
Reporting - Sonar
Want some more?
• Maven books from Sonatype
https://www.sonatype.com/ebooks
• pom.xml reference
• Maven Plugins reference
o Apache
o Codehaus

More Related Content

What's hot

Workshop MSF4J - Getting Started with Microservices and Java
Workshop MSF4J - Getting Started with Microservices and JavaWorkshop MSF4J - Getting Started with Microservices and Java
Workshop MSF4J - Getting Started with Microservices and JavaEdgar Silva
 
[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)
[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)
[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)OpenStack Korea Community
 
Maven 3 Overview
Maven 3  OverviewMaven 3  Overview
Maven 3 OverviewMike Ensor
 
Introduction tomaven
Introduction tomavenIntroduction tomaven
Introduction tomavenManav Prasad
 
OpenStack Contribution Workflow
OpenStack Contribution WorkflowOpenStack Contribution Workflow
OpenStack Contribution WorkflowSean McGinnis
 
Boris Stoyanov - Troubleshooting the Virtual Router - Run and Get Diagnostics
Boris Stoyanov - Troubleshooting the Virtual Router - Run and Get DiagnosticsBoris Stoyanov - Troubleshooting the Virtual Router - Run and Get Diagnostics
Boris Stoyanov - Troubleshooting the Virtual Router - Run and Get DiagnosticsShapeBlue
 
Multi-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and moreMulti-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and moreChef Software, Inc.
 
On HBase Integration Testing
On HBase Integration TestingOn HBase Integration Testing
On HBase Integration TestingAndrewPurtell
 
Spring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics MonitoringSpring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics MonitoringDonghuKIM2
 
MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)Kenny Gryp
 
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...SaltStack
 
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)Simon Boulet
 
JavaDay Kiev 2017 - Integration testing with TestContainers
JavaDay Kiev 2017 - Integration testing with TestContainersJavaDay Kiev 2017 - Integration testing with TestContainers
JavaDay Kiev 2017 - Integration testing with TestContainersAnton Arhipov
 
Submitting and Reviewing changes lab guide
Submitting and Reviewing changes lab guideSubmitting and Reviewing changes lab guide
Submitting and Reviewing changes lab guideopenstackcisco
 
Jabox presentation
Jabox presentationJabox presentation
Jabox presentationspiddy
 

What's hot (20)

Workshop MSF4J - Getting Started with Microservices and Java
Workshop MSF4J - Getting Started with Microservices and JavaWorkshop MSF4J - Getting Started with Microservices and Java
Workshop MSF4J - Getting Started with Microservices and Java
 
[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)
[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)
[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)
 
Maven 3 Overview
Maven 3  OverviewMaven 3  Overview
Maven 3 Overview
 
Openstack bug list
Openstack bug listOpenstack bug list
Openstack bug list
 
Introduction tomaven
Introduction tomavenIntroduction tomaven
Introduction tomaven
 
OpenStack Contribution Workflow
OpenStack Contribution WorkflowOpenStack Contribution Workflow
OpenStack Contribution Workflow
 
Dev stacklabguide
Dev stacklabguideDev stacklabguide
Dev stacklabguide
 
Boris Stoyanov - Troubleshooting the Virtual Router - Run and Get Diagnostics
Boris Stoyanov - Troubleshooting the Virtual Router - Run and Get DiagnosticsBoris Stoyanov - Troubleshooting the Virtual Router - Run and Get Diagnostics
Boris Stoyanov - Troubleshooting the Virtual Router - Run and Get Diagnostics
 
Vagrant to-aws-flow
Vagrant to-aws-flowVagrant to-aws-flow
Vagrant to-aws-flow
 
Multi-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and moreMulti-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and more
 
On HBase Integration Testing
On HBase Integration TestingOn HBase Integration Testing
On HBase Integration Testing
 
Spring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics MonitoringSpring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics Monitoring
 
Ex407
Ex407Ex407
Ex407
 
Deep dive networking
Deep dive networkingDeep dive networking
Deep dive networking
 
MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)
 
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
 
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
 
JavaDay Kiev 2017 - Integration testing with TestContainers
JavaDay Kiev 2017 - Integration testing with TestContainersJavaDay Kiev 2017 - Integration testing with TestContainers
JavaDay Kiev 2017 - Integration testing with TestContainers
 
Submitting and Reviewing changes lab guide
Submitting and Reviewing changes lab guideSubmitting and Reviewing changes lab guide
Submitting and Reviewing changes lab guide
 
Jabox presentation
Jabox presentationJabox presentation
Jabox presentation
 

Viewers also liked (10)

Sonar system
Sonar systemSonar system
Sonar system
 
Alfresco Mavenisation
Alfresco MavenisationAlfresco Mavenisation
Alfresco Mavenisation
 
Sonar Metrics
Sonar MetricsSonar Metrics
Sonar Metrics
 
Sonar
SonarSonar
Sonar
 
Sonar Overview
Sonar OverviewSonar Overview
Sonar Overview
 
SONAR
SONAR SONAR
SONAR
 
Robot PowerPoint
Robot PowerPointRobot PowerPoint
Robot PowerPoint
 
robotics ppt
robotics ppt robotics ppt
robotics ppt
 
Basics of Robotics
Basics of RoboticsBasics of Robotics
Basics of Robotics
 
Robotics project ppt
Robotics project pptRobotics project ppt
Robotics project ppt
 

Similar to Maven overview

Introduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOpsIntroduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOpsSISTechnologies
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by ExampleHsi-Kai Wang
 
maven
mavenmaven
mavenakd11
 
Java, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialJava, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialRaghavan Mohan
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and AntDavid Noble
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - ExplainedSmita Prasad
 
Apache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT AcademyApache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT AcademyVolodymyr Ostapiv
 
Introduction To Maven2
Introduction To Maven2Introduction To Maven2
Introduction To Maven2Shuji Watanabe
 
How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.Fazreil Amreen Abdul Jalil
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Introboyw165
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with MavenSid Anand
 
Apache maven, a software project management tool
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management toolRenato Primavera
 

Similar to Maven overview (20)

Introduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOpsIntroduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOps
 
Ant, Maven and Jenkins
Ant, Maven and JenkinsAnt, Maven and Jenkins
Ant, Maven and Jenkins
 
Maven
MavenMaven
Maven
 
Apache Maven for AT/QC
Apache Maven for AT/QCApache Maven for AT/QC
Apache Maven for AT/QC
 
Apache Maven basics
Apache Maven basicsApache Maven basics
Apache Maven basics
 
4 maven junit
4 maven junit4 maven junit
4 maven junit
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by Example
 
maven
mavenmaven
maven
 
MAVEN
MAVENMAVEN
MAVEN
 
Java, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialJava, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorial
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and Ant
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
Apache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT AcademyApache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT Academy
 
Introduction To Maven2
Introduction To Maven2Introduction To Maven2
Introduction To Maven2
 
Maven basics
Maven basicsMaven basics
Maven basics
 
How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
Apache maven, a software project management tool
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management tool
 

Recently uploaded

NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarPrecisely
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 

Recently uploaded (20)

NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
20150722 - AGV
20150722 - AGV20150722 - AGV
20150722 - AGV
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 

Maven overview

  • 2. Apache Maven history • Started by Jason Van Zyl in 2001 o Standardising the build of Apache Turbine • Version history o 1.0 in Jul-2004, after loads of betas o 2.0 in Oct-2005, completely redesigned o 3.0 in Oct-2010, fully compatible o 3.5.0 is the latest, released Apr-2017 • Previsouly somewhat controlled by Sonatype • Strong and stable!
  • 3. Maven is *not* a better Ant <project> <target name="compile"> <javac ...> </target> <target name="test"> <junit ..> </target> <target name="package"> <jar ..> </target> </project> <project> <groupId>org.alfresco</> <artifactId>alfresco-core</> <version>5.1.0</> <name>Alfresco Core</> <dependencies> <dependency> <groupId>commons-logging</> <artifactId>commons-logging</> <version>1.1</> </dependency> </dependencies> </project> build.xml pom.xml
  • 4. Maven is *not* a better Ant <project> <target name="compile"> <javac ...> </target> <target name="test"> <junit ..> </target> <target name="package"> <jar ..> </target> </project> build.xml pom.xml CODE <project> <groupId>org.alfresco</> <artifactId>alfresco-core</> <version>5.1.0</> <name>Alfresco Core</> <dependencies> <dependency> <groupId>commons-logging</> <artifactId>commons-logging</> <version>1.1</> </dependency> </dependencies> </project> DATA
  • 5. Maven plugins • Written in Java (MOJO), or ... • Entry-points are called goals • Examples: o Core  maven-compiler-plugin  maven-resources-plugin - including filtering  maven-surefire-plugin - executes tests o Reporting  maven-javadoc-plugin  maven-findbugs-plugin o Code Generation  antlr3-maven-plugin o maven-alfresco-plugin !! o .......
  • 7. Maven phases Phase Default binding for jar packaging initialize generate-sources process-resources resources:resources compile compiler:compile generate-test-sources process-test-resources resources:testResources test-compile compiler:testCompile test surefire:test package jar:jar pre-integration-test integration-test post-integration-test install install:install deploy deploy:deploy
  • 8. Plugging a plug-in <plugin> <artifactId>maven-jetty-plugin</artifactId> <executions> <execution> <id>start-jetty</id> <phase>pre-integration-test</phase> <goals> <goal>run</goal> </goals> </execution> <execution> <id>stop-jetty</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> <configuration> <port>9876</port> </configuration> </plugin>
  • 9. Maven conventions • tree layout o pom.xml o src  main • java • resources  test • java • resources o target • tests are executed as part of the build Follow the Maven way!
  • 10. Maven dependency A dependency (internal or external) is made of: • mandatory : GAV o groupId (org.alfresco) o artifactId (alfresco-datamodel) o version  release: 4.1.0  snapshot: 4.1.0-SNAPSHOT • optionally: o scope (compile, test, provided, ...) o classifier (jdk6, sources, javadocs, ...) Dependencies are transitive! • mvn dependency:tree dependency:list
  • 11. Maven dependency management mvnlocal Maven repo ~/.m2/repository Maven Central http://repo.maven.apache.org/maven2/ mvn install
  • 12. Maven dependency management mvnmvn install Team Repo Maven Central http://repo.maven.apache.org/maven2/ local Maven repo ~/.m2/repository
  • 13. Invoking Maven • call a phase o mvn clean install o mvn test • call a goal o mvn surefire:test o mvn javadoc:javadoc • Useful switches o -o : offline o -U : force check for snapshot updates o -X : verbose, to check plugin configuration • Adding command-line params for plugins o -DskipTests o -Dtest=MyClassTest
  • 14. Multimodule builds • call sub-projects in parent folder <packaging>pom</packaging> <modules> <module>core</module> <module>web-client</module> </modules> • pom inheritance in sub-projects <parent> <groupId>... <artifactId>... <version>... </parent> • Computing the actual pom mvn help:effective-pom
  • 15. Maven profiles • conditional parts in the pom.xml o plug/unplug a submodule o run a different set of tests o test various platforms o ... • Triggering a profile o command line: -Pprofile1,!profile3 o presence/absence of a property o automatic: JDK, OS, platform, existence of a file, …
  • 16. IDE integration • "Old school": Maven generating IDE project o mvn eclipse:eclipse [-DdownloadSources=true] o mvn idea:idea o mvn netbeans:netbeans • Recommended: IDE directly reading pom.xml o m2e plugin, included in "Eclipse IDE for Java Devs"
  • 19. Want some more? • Maven books from Sonatype https://www.sonatype.com/ebooks • pom.xml reference • Maven Plugins reference o Apache o Codehaus

Editor's Notes

  1. "convention over configuration" guarantees success!
  2. First thing that maven downloads is itself! plugins, etc. ("Maven downloads the internet")
  3. Adding a Maven repo for the team to proxy central share internal artifacts between team members share releases with outsiders (until we're on central...)