SlideShare a Scribd company logo
1 of 40
An Introduction to Apache




                            Author: Vadim Lotar (QC Backend)
                                                        2011
Agenda
 Automation Build Tool
 A bit of history
 Why Maven?
 An Introduction to Maven
 Drawbacks of Maven
 Best practices
 Maven in software development suite
 Examples
 Q&A
Automation Build Tool
   Since the early days of modern
    engineering, automation of build
    processes has been the key to:

     Productivity improvements
     Quality insurance
     Eliminate dependencies on key
      personnel
     Save time and money


   Why would software development
    be any different?
Automation Build Tool
   How do you really enable automation of
    build?

     Build has to be reproducible


     Build has to produce the final production artifact


     Build has to be as easy to maintain as possible
     and well documented
Agenda
 Automation Build Tool
 A bit of history
 Why Maven?
 An Introduction to Maven
 Drawbacks of Maven
 Best practices
 Maven in software development suite
 Examples
 Q&A
A bit of history
   A simple script (.sh, .bat) is already a possible
    solution

   More advanced command-line tools have been
    available for a long time

   make created in 1977 at Bells Labs by Stuart
    Feldman. Still very much used nowadays

   Apache Ant created by James Duncan Davidson
A bit of history
Two main categories in current tools:
 Scripting tools
   Ant
   Rake (Ruby based)
   Gradle (Groovy based)
   … many others


   Artifact oriented tools
     Maven
     Debian Package Creation
A bit of history
   Maven 1.x is now almost 12 years old
    project, mostly motionless since 2007 (I cannot
    find anybody still using it or committing to it)
   Maven 2.x was the de facto standard for Java and
    Java EE build
     Most open source projects were switched to
       Maven for their build system
     It’s now seven years old
   Maven 3.x is used in > 90% of Java (EE) startup
    applications.
     It’s now two years old
     Last release – ver. 3.0.3
Agenda
   Automation Build Tool
   A bit of history
   Why Maven?
   An Introduction to Maven
   Drawbacks of Maven
   Best practices
   Maven in software development suite
   Examples
   Q&A
Why Maven?
   If you are not already using it:
     Now is the best moment to start being aware
     Maven is mature
     Maven is getting better and better
     Maven can be used online and offline
   If you are already using it:
     Hang on! The best is yet to come!
     Focus on necessary things and don’t get
       frustrated by petty details
Agenda
 Automation Build Tool
 A bit of history
 Why Maven?
 An Introduction to Maven
 Drawbacks of Maven
 Best practices
 Maven in software development suite
 Examples
 Q&A
An Introduction to Maven
Maven is a tool with multiple facets:

   a BUILD tool

   a DEPENDENCY MANAGEMENT tool

   a DOCUMENTATION tool
An Introduction to Maven
     Project Object Model
     pom.xml




       Maven’s working …

   Generated artifacts (jar, war, ear…),
   Documentation, statistics (test
    results, quality metrics, javadoc, web
    site)…
An Introduction to Maven
   A project can easily be cut into modules
    thanks to Maven
   By simply declaring project metadata and
    optionally configuring a few plug-ins, you can:
     Build your project (compile, generate
      sources…)
     Launch tests and gather results
      (Junit, TestNG, Selenium…etc)
     Package (Jar, War, Ejb, War…etc)
     Document and generate reports
An Introduction to Maven
Project Object Model (POM)
 Basic project information
     groupId, artifactId, version…
     Inheritance, or Aggregation through sub-modules
      (will explain the difference later on)
   Build section
     Project layout (sources and resources folders… etc)
     Build plugins configuration
   Reporting section
     Reports configuration
   Some other advanced environment settings
An Introduction to Maven
An Introduction to Maven
   A plug-in is made of a MOJO (Maven POJO)
    which is simply a java class with Maven-
    specific metadata.
   A plug-in can define goals and reports
   Goals can be called directly:
     mvn plugin:goal
   Goals can be bound to one or multiple phases
   Reports are used during site generation
     mvn site
An Introduction to Maven
An Introduction to Maven
An Introduction to Maven
   When you invoke a phase, Maven will go
    through all the phases until the one
    specified, executing the bound goals:
     mvn package
An Introduction to Maven
 There are many more phases than in
  previous examples in the default lifecycle
 By default, all the basic necessary plug-ins
  for the build phase are already bound to
  phases
 It is easy to have information about plugins:
     mvn help:describe
   So….. what’s left to do, and what’s all the
    fuss about the complexity of Maven?
An Introduction to Maven
Dependencies: A blessing and a curse
 Blessing:
     Transitive dependencies
     easier to find/discover/use java libraries
   Curse:
     Transitive dependencies can rapidly trigger
      a dependency hell!
     Harder to stabilize builds
An Introduction to Maven
   What really made Maven different from other
    builds systems in the first place?

   REPOSITORIES!!!

   Before Maven, it was really hard to find java
    libraries, and harder to ensure a coherent use
    of these libraries

   Nowadays, it’s still very hard to find some jars
    with a decent/coherent versioning, let alone to
    find their sources or javadocs
An Introduction to Maven
   Local repository:
     Local cache for artifacts
     Contain temporary build artifacts
     It’s possible to erase it regularly
     Very useful for offline builds
   By default in user home’s .m2/repository folder
   Can be moved to another place through
    Maven runtime’ settings.xml file
   $MAVEN_HOME/conf/settings.xml
An Introduction to Maven
   Corporate repository/proxy
     Access via file:// and http://
     The first necessary step towards a corporate use of
      maven
   The local and remote repositories are structured
    the same
   Even better: install a repository management tool
     Can proxy external repositories
     Can filter unwanted artifacts
An Introduction to Maven
   Public repositories
     Good for dependencies’ harvesting
     A lot of mis-configured dependencies
     A lot of alpha/beta Maven plugins and
      libraries


   Be cautious when adding public repositories to
    a build process!
       Should be proxied in corporate
An Introduction to Maven
Other key features of Maven:

 POM Inheritance/Aggregation
 Archetypes
 Launching Tests
 … many more…
An Introduction to Maven
   POM – Project Object Model

   Super POM

   Inheritance

   Aggregation

   Inheritance vs Aggregation
An Introduction to Maven
Project Archetypes

   You can build template projects and make them
    available as artifacts in the repositories
       mvn archetype:create-from-project
   Allows to share best practices without neither
    inheritance nor aggregation
     mvn archetype:generate
   Many Archetypes already configured in the default
    catalog

   You can easily build a custom or corporate catalog
    mvn archetype:generate
    –DarchetypeCatalog=http://www.corporate.com/archetypes.xml
An Introduction to Maven
Archetype ArtifactIds         Description
maven-archetype-archetype     An archetype which contains a sample
                              archetype.
maven-archetype-j2ee-simple   An archetype which contains a simplifed sample
                              J2EE application.
maven-archetype-mojo          An archetype which contains a sample a sample
                              Maven plugin.
maven-archetype-plugin        An archetype which contains a sample Maven
                              plugin.
maven-archetype-plugin-site   An archetype which contains a sample Maven
                              plugin site.
maven-archetype-portlet       An archetype which contains a sample JSR-268
                              Portlet.
maven-archetype-quickstart    An archetype which contains a sample Maven
                              project.
maven-archetype-simple        An archetype which contains a simple Maven
                              project.
maven-archetype-site          An archetype which contains a sample Maven
                              site which demonstrates some of the supported
                              document types like APT, XDoc, and FML and
                              demonstrates how to i18n your site.
maven-archetype-site-simple   An archetype which contains a sample Maven
                              site.
maven-archetype-webapp        An archetype which contains a sample Maven
                              Webapp project.
An Introduction to Maven
Launching Tests

   Maven allows to launch various types of tests:
     Unit tests: Junit 3.x or 4.x, TestNG, …
     UI Tests: Selenium, Canoo Webtest
     Functional tests: Fitnesse, Greenpepper
     WebServices tests: SOAPUi
     And many more…
Agenda
 Automation Build Tool
 A bit of history
 Why Maven?
 An Introduction to Maven
 Drawbacks of Maven
 Best practices
 Maven in software development suite
 Examples
 Q&A
Drawbacks of Maven
   Library repositories are not always safe.

   Maven Conventions

   Hard to find some things about maven and
    plugins

   A huge output log

   Sequential build (Lyfecycle)

   Learning Maven is long in comparison of Ant.
Agenda
   Automation Build Tool
   A bit of history
   Why Maven?
   An Introduction to Maven
   Drawbacks of Maven
   Best practices
   Maven in software development suite
   Examples
   Q&A
Best practices
   Embrace the standardization brought by Maven, don’t
    fight it

   Use POM Inheritance and <dependencyManagement>
    (with import scope), <pluginManagement>

   Use a Repository Manager:
     Sonatype Nexus: http://nexus.sonatype.org
     Jfrog Artifactory: http://artifactory.jfrog.org
     …
Best practices
   Keep your build as simple as possible

   Launch your builds regularly and possibly in a neutral
    zone

   Use the “dependency” and “versions” plugins

   Generate test statistics data and other metrics data in
    order to exploit them in Software quality tools:
     Sonar: http://sonar.codehaus.org
     Squale: http://www.squale.org
     …
Agenda
 Automation Build Tool
 A bit of history
 Why Maven?
 An Introduction to Maven
 Drawbacks of Maven
 Best practices
 Maven in software development suite
 Examples
 Q&A
Maven in a Software development
suite
   Maven is now very well integrated in IDEs
     NetBeans 6.5+ now has very good support for
      Maven
     Eclipse 3.x has very good support also.
     IntelliJ IDEA seems to have excellent support
      also (though this is why you pay for it isn’t it?)
 Maven works very well with Quality
  monitoring tools
 Continuous integration
References and Thanks
Documentation and information:
 Site http://maven.apache.org
 Plugins
     http://maven.apache.org/plugins
     http://mojo.codehaus.org/
     http://code.google.com/
     And many others…
   Project Wiki
    http://docs.codehaus.org/display/MAVEN/
   Users’ Wiki
    http://docs.codehaus.org/display/MAVENUSER
References and Thanks
Books
 Free electronic editions:
 Definitive Guide: http://www.sonatype.com/books
 Better Builds with Maven:
  http://www.maestrodev.com/better-build-maven
 Upcoming book by Arnaud Héritier and Nicolas De Loof
  http://www.pearson.fr/livre/?GCOI=27440100730370

Thanks
 Many thanks to Pierre-Antoine Grégoire for its
  presentation on YaJUG
 Thanks to Jason van Zyl for its Maven 3 presentation
  http://www.sonatype.com/people/author/jason

More Related Content

What's hot

Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introductionRasheed Waraich
 
Jenkins Introduction
Jenkins IntroductionJenkins Introduction
Jenkins IntroductionPavan Gupta
 
Introduction to Apache Maven
Introduction to Apache MavenIntroduction to Apache Maven
Introduction to Apache MavenRajind Ruparathna
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot IntroductionJeevesh Pandey
 
What is Jenkins | Jenkins Tutorial for Beginners | Edureka
What is Jenkins | Jenkins Tutorial for Beginners | EdurekaWhat is Jenkins | Jenkins Tutorial for Beginners | Edureka
What is Jenkins | Jenkins Tutorial for Beginners | EdurekaEdureka!
 
Jenkins tutorial for beginners
Jenkins tutorial for beginnersJenkins tutorial for beginners
Jenkins tutorial for beginnersBugRaptors
 
The story of SonarQube told to a DevOps Engineer
The story of SonarQube told to a DevOps EngineerThe story of SonarQube told to a DevOps Engineer
The story of SonarQube told to a DevOps EngineerManu Pk
 
Build tools introduction
Build tools introductionBuild tools introduction
Build tools introductionvodQA
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to MavenJoao Pereira
 

What's hot (20)

Apache maven 2 overview
Apache maven 2 overviewApache maven 2 overview
Apache maven 2 overview
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Maven
MavenMaven
Maven
 
Xke spring boot
Xke spring bootXke spring boot
Xke spring boot
 
Maven
MavenMaven
Maven
 
Spring boot
Spring bootSpring boot
Spring boot
 
Jenkins Introduction
Jenkins IntroductionJenkins Introduction
Jenkins Introduction
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Maven
MavenMaven
Maven
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
Jenkins tutorial
Jenkins tutorialJenkins tutorial
Jenkins tutorial
 
Introduction to Apache Maven
Introduction to Apache MavenIntroduction to Apache Maven
Introduction to Apache Maven
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
What is Jenkins | Jenkins Tutorial for Beginners | Edureka
What is Jenkins | Jenkins Tutorial for Beginners | EdurekaWhat is Jenkins | Jenkins Tutorial for Beginners | Edureka
What is Jenkins | Jenkins Tutorial for Beginners | Edureka
 
Jenkins tutorial for beginners
Jenkins tutorial for beginnersJenkins tutorial for beginners
Jenkins tutorial for beginners
 
The story of SonarQube told to a DevOps Engineer
The story of SonarQube told to a DevOps EngineerThe story of SonarQube told to a DevOps Engineer
The story of SonarQube told to a DevOps Engineer
 
Build tools introduction
Build tools introductionBuild tools introduction
Build tools introduction
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to Maven
 

Similar to An Introduction to Apache Maven: The Automated Build Tool

Maven 2 features
Maven 2 featuresMaven 2 features
Maven 2 featuresAngel Ruiz
 
Maven introduction
Maven introductionMaven introduction
Maven introductionLai Hieu
 
Iam New And Noteworthy
Iam New And NoteworthyIam New And Noteworthy
Iam New And NoteworthyAbel Muíño
 
Maven in mulesoft
Maven in mulesoftMaven in mulesoft
Maven in mulesoftvenkata20k
 
Maven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsMaven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsSteve Keener
 
Apache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT AcademyApache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT AcademyVolodymyr Ostapiv
 
How can you improve, harmonize and automate your development process using to...
How can you improve, harmonize and automate your development process using to...How can you improve, harmonize and automate your development process using to...
How can you improve, harmonize and automate your development process using to...John Ferguson Smart Limited
 
Maven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafeMaven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafeHolasz Kati
 
Build Automation using Maven
Build Automation using Maven Build Automation using Maven
Build Automation using Maven Ankit Gubrani
 
Testing Java Web Apps With Selenium
Testing Java Web Apps With SeleniumTesting Java Web Apps With Selenium
Testing Java Web Apps With SeleniumMarakana Inc.
 
SE2018_Lec-22_-Continuous-Integration-Tools
SE2018_Lec-22_-Continuous-Integration-ToolsSE2018_Lec-22_-Continuous-Integration-Tools
SE2018_Lec-22_-Continuous-Integration-ToolsAmr E. Mohamed
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svnAnkur Goyal
 

Similar to An Introduction to Apache Maven: The Automated Build Tool (20)

Maven 2 features
Maven 2 featuresMaven 2 features
Maven 2 features
 
Maven introduction
Maven introductionMaven introduction
Maven introduction
 
Maven
MavenMaven
Maven
 
What is maven
What is mavenWhat is maven
What is maven
 
Iam New And Noteworthy
Iam New And NoteworthyIam New And Noteworthy
Iam New And Noteworthy
 
Maven in mulesoft
Maven in mulesoftMaven in mulesoft
Maven in mulesoft
 
Maven basics
Maven basicsMaven basics
Maven basics
 
Maven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsMaven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable Results
 
Team Maven
Team MavenTeam Maven
Team Maven
 
Apache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT AcademyApache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT Academy
 
How can you improve, harmonize and automate your development process using to...
How can you improve, harmonize and automate your development process using to...How can you improve, harmonize and automate your development process using to...
How can you improve, harmonize and automate your development process using to...
 
Mavennotes.pdf
Mavennotes.pdfMavennotes.pdf
Mavennotes.pdf
 
Maven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafeMaven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafe
 
Build Automation using Maven
Build Automation using Maven Build Automation using Maven
Build Automation using Maven
 
Maven
MavenMaven
Maven
 
Maven overview
Maven overviewMaven overview
Maven overview
 
Testing Java Web Apps With Selenium
Testing Java Web Apps With SeleniumTesting Java Web Apps With Selenium
Testing Java Web Apps With Selenium
 
SE2018_Lec-22_-Continuous-Integration-Tools
SE2018_Lec-22_-Continuous-Integration-ToolsSE2018_Lec-22_-Continuous-Integration-Tools
SE2018_Lec-22_-Continuous-Integration-Tools
 
Manen Ant SVN
Manen Ant SVNManen Ant SVN
Manen Ant SVN
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svn
 

Recently uploaded

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Recently uploaded (20)

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 

An Introduction to Apache Maven: The Automated Build Tool

  • 1. An Introduction to Apache Author: Vadim Lotar (QC Backend) 2011
  • 2. Agenda  Automation Build Tool  A bit of history  Why Maven?  An Introduction to Maven  Drawbacks of Maven  Best practices  Maven in software development suite  Examples  Q&A
  • 3. Automation Build Tool  Since the early days of modern engineering, automation of build processes has been the key to:  Productivity improvements  Quality insurance  Eliminate dependencies on key personnel  Save time and money  Why would software development be any different?
  • 4. Automation Build Tool  How do you really enable automation of build?  Build has to be reproducible  Build has to produce the final production artifact  Build has to be as easy to maintain as possible and well documented
  • 5. Agenda  Automation Build Tool  A bit of history  Why Maven?  An Introduction to Maven  Drawbacks of Maven  Best practices  Maven in software development suite  Examples  Q&A
  • 6. A bit of history  A simple script (.sh, .bat) is already a possible solution  More advanced command-line tools have been available for a long time  make created in 1977 at Bells Labs by Stuart Feldman. Still very much used nowadays  Apache Ant created by James Duncan Davidson
  • 7. A bit of history Two main categories in current tools:  Scripting tools  Ant  Rake (Ruby based)  Gradle (Groovy based)  … many others  Artifact oriented tools  Maven  Debian Package Creation
  • 8. A bit of history  Maven 1.x is now almost 12 years old project, mostly motionless since 2007 (I cannot find anybody still using it or committing to it)  Maven 2.x was the de facto standard for Java and Java EE build  Most open source projects were switched to Maven for their build system  It’s now seven years old  Maven 3.x is used in > 90% of Java (EE) startup applications.  It’s now two years old  Last release – ver. 3.0.3
  • 9. Agenda  Automation Build Tool  A bit of history  Why Maven?  An Introduction to Maven  Drawbacks of Maven  Best practices  Maven in software development suite  Examples  Q&A
  • 10. Why Maven?  If you are not already using it:  Now is the best moment to start being aware  Maven is mature  Maven is getting better and better  Maven can be used online and offline  If you are already using it:  Hang on! The best is yet to come!  Focus on necessary things and don’t get frustrated by petty details
  • 11. Agenda  Automation Build Tool  A bit of history  Why Maven?  An Introduction to Maven  Drawbacks of Maven  Best practices  Maven in software development suite  Examples  Q&A
  • 12. An Introduction to Maven Maven is a tool with multiple facets:  a BUILD tool  a DEPENDENCY MANAGEMENT tool  a DOCUMENTATION tool
  • 13. An Introduction to Maven Project Object Model pom.xml Maven’s working …  Generated artifacts (jar, war, ear…),  Documentation, statistics (test results, quality metrics, javadoc, web site)…
  • 14. An Introduction to Maven  A project can easily be cut into modules thanks to Maven  By simply declaring project metadata and optionally configuring a few plug-ins, you can:  Build your project (compile, generate sources…)  Launch tests and gather results (Junit, TestNG, Selenium…etc)  Package (Jar, War, Ejb, War…etc)  Document and generate reports
  • 15. An Introduction to Maven Project Object Model (POM)  Basic project information  groupId, artifactId, version…  Inheritance, or Aggregation through sub-modules (will explain the difference later on)  Build section  Project layout (sources and resources folders… etc)  Build plugins configuration  Reporting section  Reports configuration  Some other advanced environment settings
  • 17. An Introduction to Maven  A plug-in is made of a MOJO (Maven POJO) which is simply a java class with Maven- specific metadata.  A plug-in can define goals and reports  Goals can be called directly:  mvn plugin:goal  Goals can be bound to one or multiple phases  Reports are used during site generation  mvn site
  • 20. An Introduction to Maven  When you invoke a phase, Maven will go through all the phases until the one specified, executing the bound goals:  mvn package
  • 21. An Introduction to Maven  There are many more phases than in previous examples in the default lifecycle  By default, all the basic necessary plug-ins for the build phase are already bound to phases  It is easy to have information about plugins:  mvn help:describe  So….. what’s left to do, and what’s all the fuss about the complexity of Maven?
  • 22. An Introduction to Maven Dependencies: A blessing and a curse  Blessing:  Transitive dependencies  easier to find/discover/use java libraries  Curse:  Transitive dependencies can rapidly trigger a dependency hell!  Harder to stabilize builds
  • 23. An Introduction to Maven  What really made Maven different from other builds systems in the first place?  REPOSITORIES!!!  Before Maven, it was really hard to find java libraries, and harder to ensure a coherent use of these libraries  Nowadays, it’s still very hard to find some jars with a decent/coherent versioning, let alone to find their sources or javadocs
  • 24. An Introduction to Maven  Local repository:  Local cache for artifacts  Contain temporary build artifacts  It’s possible to erase it regularly  Very useful for offline builds  By default in user home’s .m2/repository folder  Can be moved to another place through Maven runtime’ settings.xml file  $MAVEN_HOME/conf/settings.xml
  • 25. An Introduction to Maven  Corporate repository/proxy  Access via file:// and http://  The first necessary step towards a corporate use of maven  The local and remote repositories are structured the same  Even better: install a repository management tool  Can proxy external repositories  Can filter unwanted artifacts
  • 26. An Introduction to Maven  Public repositories  Good for dependencies’ harvesting  A lot of mis-configured dependencies  A lot of alpha/beta Maven plugins and libraries  Be cautious when adding public repositories to a build process!  Should be proxied in corporate
  • 27. An Introduction to Maven Other key features of Maven:  POM Inheritance/Aggregation  Archetypes  Launching Tests  … many more…
  • 28. An Introduction to Maven  POM – Project Object Model  Super POM  Inheritance  Aggregation  Inheritance vs Aggregation
  • 29. An Introduction to Maven Project Archetypes  You can build template projects and make them available as artifacts in the repositories  mvn archetype:create-from-project  Allows to share best practices without neither inheritance nor aggregation  mvn archetype:generate  Many Archetypes already configured in the default catalog  You can easily build a custom or corporate catalog mvn archetype:generate –DarchetypeCatalog=http://www.corporate.com/archetypes.xml
  • 30. An Introduction to Maven Archetype ArtifactIds Description maven-archetype-archetype An archetype which contains a sample archetype. maven-archetype-j2ee-simple An archetype which contains a simplifed sample J2EE application. maven-archetype-mojo An archetype which contains a sample a sample Maven plugin. maven-archetype-plugin An archetype which contains a sample Maven plugin. maven-archetype-plugin-site An archetype which contains a sample Maven plugin site. maven-archetype-portlet An archetype which contains a sample JSR-268 Portlet. maven-archetype-quickstart An archetype which contains a sample Maven project. maven-archetype-simple An archetype which contains a simple Maven project. maven-archetype-site An archetype which contains a sample Maven site which demonstrates some of the supported document types like APT, XDoc, and FML and demonstrates how to i18n your site. maven-archetype-site-simple An archetype which contains a sample Maven site. maven-archetype-webapp An archetype which contains a sample Maven Webapp project.
  • 31. An Introduction to Maven Launching Tests  Maven allows to launch various types of tests:  Unit tests: Junit 3.x or 4.x, TestNG, …  UI Tests: Selenium, Canoo Webtest  Functional tests: Fitnesse, Greenpepper  WebServices tests: SOAPUi  And many more…
  • 32. Agenda  Automation Build Tool  A bit of history  Why Maven?  An Introduction to Maven  Drawbacks of Maven  Best practices  Maven in software development suite  Examples  Q&A
  • 33. Drawbacks of Maven  Library repositories are not always safe.  Maven Conventions  Hard to find some things about maven and plugins  A huge output log  Sequential build (Lyfecycle)  Learning Maven is long in comparison of Ant.
  • 34. Agenda  Automation Build Tool  A bit of history  Why Maven?  An Introduction to Maven  Drawbacks of Maven  Best practices  Maven in software development suite  Examples  Q&A
  • 35. Best practices  Embrace the standardization brought by Maven, don’t fight it  Use POM Inheritance and <dependencyManagement> (with import scope), <pluginManagement>  Use a Repository Manager:  Sonatype Nexus: http://nexus.sonatype.org  Jfrog Artifactory: http://artifactory.jfrog.org  …
  • 36. Best practices  Keep your build as simple as possible  Launch your builds regularly and possibly in a neutral zone  Use the “dependency” and “versions” plugins  Generate test statistics data and other metrics data in order to exploit them in Software quality tools:  Sonar: http://sonar.codehaus.org  Squale: http://www.squale.org  …
  • 37. Agenda  Automation Build Tool  A bit of history  Why Maven?  An Introduction to Maven  Drawbacks of Maven  Best practices  Maven in software development suite  Examples  Q&A
  • 38. Maven in a Software development suite  Maven is now very well integrated in IDEs  NetBeans 6.5+ now has very good support for Maven  Eclipse 3.x has very good support also.  IntelliJ IDEA seems to have excellent support also (though this is why you pay for it isn’t it?)  Maven works very well with Quality monitoring tools  Continuous integration
  • 39. References and Thanks Documentation and information:  Site http://maven.apache.org  Plugins  http://maven.apache.org/plugins  http://mojo.codehaus.org/  http://code.google.com/  And many others…  Project Wiki http://docs.codehaus.org/display/MAVEN/  Users’ Wiki http://docs.codehaus.org/display/MAVENUSER
  • 40. References and Thanks Books  Free electronic editions:  Definitive Guide: http://www.sonatype.com/books  Better Builds with Maven: http://www.maestrodev.com/better-build-maven  Upcoming book by Arnaud Héritier and Nicolas De Loof http://www.pearson.fr/livre/?GCOI=27440100730370 Thanks  Many thanks to Pierre-Antoine Grégoire for its presentation on YaJUG  Thanks to Jason van Zyl for its Maven 3 presentation http://www.sonatype.com/people/author/jason