SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Downloaden Sie, um offline zu lesen
+




    Maven 3 quick overview

    Mike Ensor
    http://www.ensor.cc
+
    Agenda

    •   Define Maven
        •   Why?
        •   Maven vs. Ant or Gradle

    •   Basic Concepts

    •   Dependency Management

    •   Repositories

    •   Deployment

    •   Releases

    •   Q&A
+
    Define Maven

    •   Apache Maven is a software project management and
        comprehension tool

    •   Based on the concept of a project object model (POM), Maven
        can manage a project's build, reporting and documentation
        from a central piece of information
+
    Why Use Maven?

                                           Web Site



                      Deployment                              Reporting




                                                                          Documentation
          Resource                                                        • JavaDoc
                                                                          • Coverage
                                                                          • Site Docs

                                           Maven



             Continuous
                                                                     Dependencies
             Integration




                               Artifacts
                               • JAR                  Tests
                               • WAR/EAR
+
    Convention over Configuration

    •   Pre-defined directory structures
        •   Source
        •   Tests
        •   Documentation
    •   Based on goals
        •   compile, test, package, install, deploy, site…
    •   Just learn the conventions!
    •   Archetype plugin for easy project creation
        •   mvn archetype:generate
+
    Maven vs. ant or Gradle

    •   Vs. ant
        •   Standardizes project structure
        •   Provides dependency management
        •   Built-in reporting and documentation
        •   Easier to setup platform independent projects

    •   Vs. Gradle
        •   More verbose project file (positive and negative)
        •   Little to no programming knowledge needed
        •   Large community support
            •   Pre-built plugins, solutions and documentation
        •   Better IDE support
            •   Except Eclipse, which does not support either well
+
    Basic Concepts

    •   POM
        •   Master & Effective

    •   Lifecycles
        •   Maven’s lifecycles

    •   Goals

    •   Plugins
        •   Plugin Management

    •   Dependencies

    •   Profiles
+
    POM

    •   File defining project/module settings
        •   XML file*
    •   “Super POM” provided by Maven
        •   Super POM used as base for all Maven projects
    •   Built-in hierarchy
        •   Settings, properties, plugins, dependencies, profiles…
        •   Use mvn help:effective-pom to generate the “used” POM
    •   Parent POM
        •   POM files can be nested allowing each project to encapsulate the
            artifact’s intent
        •   Defines base versions for common dependencies, reporting,
            profiles and plugins
    •   One POM per module
+
    POM – Important Attributes
    •   <artifactId/>                       •       <distributionManagement/>
        • Artifact’s name, must be unique           • Controls where artifact is
          within groupID scope                        deployed to
    •   <groupId/>                          •       <parent/>
        • Typically package name for                • Hierarchy of the project
          project
                                            •       <version/>
    •   <version/>
                                                    • Current version of the artifact
        • Current version of the artifact
                                            •       <scm/>
    •   <name/>
                                                    • Source code management
        • Name of the app, IDEs typically             section
          use this
                                            •       <dependencyManagement/>
    •   <packaging/>
                                                    • Defaults for dependencies
        • Type of artifact packaging
                                                •   <dependencies/>
        • POM, jar, WAR, EAR, EJB,
                                                    • Dependency definitions
          bundle
+
    POM – Important Attributes
<project …>
  <groupId>com.example</groupId>
  <artifactId>some-webapp</artifactId>
  <packaging>war</packaging>
  <version>0.01-SNAPSHOT</version>
  <name>${project.artifactId}</name>
  <distributionManagement>
    <snapshotRepository>
        <id>releases</id>
        <name>Mobile Snapshot Nexus</name>
        <url>http://nexus.kohls.com/content/repositories/Snapshots</url>
     </snapshotRepository>
     <repository>
        <id>releases</id>
        <name>Mobile Release Nexus</name>
        <url>http://nexus.kohls.com/content/repositories/releases</url>
     </repository>
     <site>
        <id>site-docs</id>
        <url>scp://${site.host}/opt/lampp/htdocs/site/${project.artifactId}</url>
     </site>
  </distributionManagement>
</project>
+
    Versioning

    •   Versions should be considered permanent
    •   SNAPSHOT builds should NEVER be deployed or released
        •   15 step process to determine which version build to use!
    •   Maven Reactor – Maven’s process to determine which
        dependencies and versions are included
    •   Initial sequence based versioning
        •   0 – for alpha
        •   1 – after first release
    •   major (dot) minor
        •   1.1, 1.11, 1.111, 1.112
    •   Attempt to keep major versions should be same on each
        module
        •   10.2.17 – 10 = major number, 2 = internal major, 17 = release
+
    Lifecycles
      •   Phases maven moves to build artifact
      •   Runs in sequential, pre-defined order
          • Ex: mvn clean site – runs clean and site
            • Note: site typically has surefire-plugin    clean
               turned on, so phases in default are run
          • Ex: mvn clean test site - runs clean,
            everything in default up thru test and then
            site                                                  default
      •   3 Core Phases
          • clean
          • default
                                                          site
          • site

      •   Clean – resets project back to known state
      •   Site – Builds documentation (“site docs”),
          reporting, JavaDocs, coverage, test results…
+
    Default Phase

    •   23 sub-phases
    •   Typically run unless only “clean” or “site” lifecycle run
        •       “site” might include default-bound goals inside of “default” phase
                such as test, generate-sources and compile
    •   Common default sub-phases
            •   generate-sources
            •   compile
            •   test
            •   package
            •   install
            •   deploy
    •   Some phases have goals bound automatically
            •   compile – compiler:compile
+
    Commands

    •   Goals – Represent specific task contributing to build phase in
        their lifecycle
        •   Goals are bound to phases
        •   Example goals: checkstyle:checkstyle
    •   Plugins – Modules adding new goals to maven
        •   Sample plugins
            • PMD
            • Checkstyle
            • JavaDocs
            • Resources (maven-resources)
            • Surefire and Failsafe
+
    Dependency Management

    •   Group                   <dependency>
                                  <groupId>com.example</groupId>
    •   Artifact                  <artifactId>random-webapp</artifactId>
                                  <packaging>war</packaging>
    •   Version                   <version>0.01</version>
                                  <scope>test</scope>
    •   Scope                   </dependency>

    •   Type

    •   Exclusions

    •   Optional

    •   Quick note: Set dependency versions and exclusions in
        <dependencyManagement/>
+
    Dependency Management – Scope

    •   Scope
        •   compile – Available in all classpaths, dependent projects inherit
            {default scope}
        •   provided – Indicates that JDK or container will provide at run-time
        •   runtime – Not required to compile, but needed to run
        •   system – Same as provided, does not look up in repository
        •   test – Available only during test phase
        •   import – When type is POM, import dependencies matching in
            <dependencyManagement/> sections
    •   Type
        • jar, pom, war, ear, ejb, bundle, maven-plugin
        • Default packaging "jar"

    •   Exclusions
    •   Optional
+
    Dependency Management – cont.
     •   Type – Specify type of artifact (common)
         •   JAR – Default type
         •   WAR – WAR, used for WAR Overlays and Uber WARs
         •   POM – Master POM or dependency POMs
     •   Exclusions – Ability to exclude dependencies from incoming
         dependencies {transitive dependencies}
         •   Used to manage transitive dependencies
     •   Optional – Method to mark transitive dependencies as excluded
         by default. Declared in incoming dependency, not in project
     •   Note: Must repeat <scope> and <type> in dependency and
         dependencyManagement sections
+
    Artifact Naming Conventions
     •   Why have naming conventions?
         •   Promotes re-use
         •   Organizes artifacts
     •   Libraries (jar type)
         • descriptive-name-lib

         • ex: common-database-lib

     •   Webapps (ear and war)
         • descriptive-name-webapp

         • ex: company-ecommerce-webapp

     •   Common dependencies
         • Groups of similar dependencies can be grouped into a “dependency
             project"
         •   descriptive-name-dep
         •   ex: common-web-dep
+
    Repositories

    •   Local – Local dependency cache
        •   ~/.m2/repository

    •   Remote – Servers that hold binaries
        •   Internet (“central”)
        •   Internal – Nexus, Artifactory…

    •   Plugin and Dependency repositories defined in POM or
        settings.xml
        •   NOTE: Best to define in settings.xml
        •   Treat <id> as a “name” for the repository; should match <id> in all
            settings.xml files in each environment
+
    Deployment
     •   Single command to deploy
         • Pushes artifact to artifact server

     •   (Almost) single command to Release
          • Release process consists of two goals
          • release:prepare
            • Strip “-SNAPSHOT” from <version/>
            • Run through site phase
            • SCM “tag” project (optional)
          • release:perform
            • Pushes artifact to artifact server
            • Increments <version/> number
            • Appends “-SNAPSHOT” to <version/>
            • Checks in (SCM) updated POM upon success
+
    Deployment: Snapshot
     •   Snapshot builds are incremental, non-versioned releases
     •   Typically used for intra-team use
     •   Use “deploy” to push snapshots to repository
         •   Repository location must be setup to accept snapshots
             •   Allow for redeploy
             •   Allow for snapshots over releases
         •   Make sure <server> setting is correct in settings.xml
     •   Typical use case:
         •   Setup a nightly SNAPSHOT build for external teams to use
             •   Minimizes changes that might cause compilation failures
+
    Q&A

    •   Lots covered…questions?

Weitere ähnliche Inhalte

Was ist angesagt? (20)

REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to Maven
 
Apache Maven
Apache MavenApache Maven
Apache Maven
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
 
Spring Core
Spring CoreSpring Core
Spring Core
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Introduction to Apache Maven
Introduction to Apache MavenIntroduction to Apache Maven
Introduction to Apache Maven
 
Tomcat server
 Tomcat server Tomcat server
Tomcat server
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Spring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutesSpring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutes
 
Making The Move To Java 17 (JConf 2022)
Making The Move To Java 17 (JConf 2022)Making The Move To Java 17 (JConf 2022)
Making The Move To Java 17 (JConf 2022)
 
Spring boot
Spring bootSpring boot
Spring boot
 

Andere mochten auch

Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for DummiesTomer Gabel
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Introboyw165
 
Análise de qualidade de código com Sonar - Fernando Boaglio
Análise de qualidade de código com Sonar - Fernando Boaglio Análise de qualidade de código com Sonar - Fernando Boaglio
Análise de qualidade de código com Sonar - Fernando Boaglio Fernando Boaglio
 
Continuous inspection with Sonar
Continuous inspection with SonarContinuous inspection with Sonar
Continuous inspection with Sonargaudol
 
Fundamental of apache maven
Fundamental of apache mavenFundamental of apache maven
Fundamental of apache mavenRajesh Kumar
 
Jornal O Engenheiro - Alexsandro Teixeira Ribeiro
Jornal O Engenheiro - Alexsandro Teixeira RibeiroJornal O Engenheiro - Alexsandro Teixeira Ribeiro
Jornal O Engenheiro - Alexsandro Teixeira RibeiroAlexsandro Teixeira Ribeiro
 
Mefe tv. el valor de la planificación
Mefe tv. el valor de la planificaciónMefe tv. el valor de la planificación
Mefe tv. el valor de la planificacióncomms planning
 
Tim Dean Producer Resume
Tim Dean Producer ResumeTim Dean Producer Resume
Tim Dean Producer ResumeTimothy Dean
 
La ubicuidad desafio_tecnologico_en_la_ensenanza
La ubicuidad desafio_tecnologico_en_la_ensenanzaLa ubicuidad desafio_tecnologico_en_la_ensenanza
La ubicuidad desafio_tecnologico_en_la_ensenanzamptic
 
Dirección de obras texto-20-08-13
Dirección de obras texto-20-08-13Dirección de obras texto-20-08-13
Dirección de obras texto-20-08-13Alberto Arias
 

Andere mochten auch (20)

Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for Dummies
 
Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Apache Maven for AT/QC
Apache Maven for AT/QCApache Maven for AT/QC
Apache Maven for AT/QC
 
Continuous delivery-with-maven
Continuous delivery-with-mavenContinuous delivery-with-maven
Continuous delivery-with-maven
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
 
Git branching model
Git branching modelGit branching model
Git branching model
 
Análise de qualidade de código com Sonar - Fernando Boaglio
Análise de qualidade de código com Sonar - Fernando Boaglio Análise de qualidade de código com Sonar - Fernando Boaglio
Análise de qualidade de código com Sonar - Fernando Boaglio
 
Continuous inspection with Sonar
Continuous inspection with SonarContinuous inspection with Sonar
Continuous inspection with Sonar
 
Git Branching Model
Git Branching ModelGit Branching Model
Git Branching Model
 
Maven tutorial for beginners
Maven tutorial for beginnersMaven tutorial for beginners
Maven tutorial for beginners
 
Fundamental of apache maven
Fundamental of apache mavenFundamental of apache maven
Fundamental of apache maven
 
MTN 4 1 09
MTN 4 1 09MTN 4 1 09
MTN 4 1 09
 
Jornal O Engenheiro - Alexsandro Teixeira Ribeiro
Jornal O Engenheiro - Alexsandro Teixeira RibeiroJornal O Engenheiro - Alexsandro Teixeira Ribeiro
Jornal O Engenheiro - Alexsandro Teixeira Ribeiro
 
Carat.quimica
Carat.quimicaCarat.quimica
Carat.quimica
 
Mefe tv. el valor de la planificación
Mefe tv. el valor de la planificaciónMefe tv. el valor de la planificación
Mefe tv. el valor de la planificación
 
Tim Dean Producer Resume
Tim Dean Producer ResumeTim Dean Producer Resume
Tim Dean Producer Resume
 
La ubicuidad desafio_tecnologico_en_la_ensenanza
La ubicuidad desafio_tecnologico_en_la_ensenanzaLa ubicuidad desafio_tecnologico_en_la_ensenanza
La ubicuidad desafio_tecnologico_en_la_ensenanza
 
Dirección de obras texto-20-08-13
Dirección de obras texto-20-08-13Dirección de obras texto-20-08-13
Dirección de obras texto-20-08-13
 

Ähnlich wie Maven 3 Overview

Practical maven-slides 2
Practical maven-slides 2Practical maven-slides 2
Practical maven-slides 2Will Iverson
 
Introduction tomaven
Introduction tomavenIntroduction tomaven
Introduction tomavenManav Prasad
 
Lorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenLorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenArnaud Héritier
 
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
 
Introduction in Apache Maven2
Introduction in Apache Maven2Introduction in Apache Maven2
Introduction in Apache Maven2Heiko Scherrer
 
Apache Maven - eXo TN presentation
Apache Maven - eXo TN presentationApache Maven - eXo TN presentation
Apache Maven - eXo TN presentationArnaud Héritier
 
S/W Design and Modularity using Maven
S/W Design and Modularity using MavenS/W Design and Modularity using Maven
S/W Design and Modularity using MavenScheidt & Bachmann
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svnAnkur Goyal
 
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
 
Developing Liferay Plugins with Maven
Developing Liferay Plugins with MavenDeveloping Liferay Plugins with Maven
Developing Liferay Plugins with MavenMika Koivisto
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topicGourav Varma
 

Ähnlich wie Maven 3 Overview (20)

4 maven junit
4 maven junit4 maven junit
4 maven junit
 
Practical maven-slides 2
Practical maven-slides 2Practical maven-slides 2
Practical maven-slides 2
 
Introduction tomaven
Introduction tomavenIntroduction tomaven
Introduction tomaven
 
Lorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenLorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - Maven
 
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.
 
Introduction in Apache Maven2
Introduction in Apache Maven2Introduction in Apache Maven2
Introduction in Apache Maven2
 
Intro to Maven.ppt
Intro to Maven.pptIntro to Maven.ppt
Intro to Maven.ppt
 
Apache Maven - eXo TN presentation
Apache Maven - eXo TN presentationApache Maven - eXo TN presentation
Apache Maven - eXo TN presentation
 
S/W Design and Modularity using Maven
S/W Design and Modularity using MavenS/W Design and Modularity using Maven
S/W Design and Modularity using Maven
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svn
 
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
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by Example
 
Introduction to maven
Introduction to mavenIntroduction to maven
Introduction to maven
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Developing Liferay Plugins with Maven
Developing Liferay Plugins with MavenDeveloping Liferay Plugins with Maven
Developing Liferay Plugins with Maven
 
Mavennotes.pdf
Mavennotes.pdfMavennotes.pdf
Mavennotes.pdf
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
 
Apache Maven
Apache MavenApache Maven
Apache Maven
 
Session 2
Session 2Session 2
Session 2
 

Kürzlich hochgeladen

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Kürzlich hochgeladen (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Maven 3 Overview

  • 1. + Maven 3 quick overview Mike Ensor http://www.ensor.cc
  • 2. + Agenda • Define Maven • Why? • Maven vs. Ant or Gradle • Basic Concepts • Dependency Management • Repositories • Deployment • Releases • Q&A
  • 3. + Define Maven • Apache Maven is a software project management and comprehension tool • Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information
  • 4. + Why Use Maven? Web Site Deployment Reporting Documentation Resource • JavaDoc • Coverage • Site Docs Maven Continuous Dependencies Integration Artifacts • JAR Tests • WAR/EAR
  • 5. + Convention over Configuration • Pre-defined directory structures • Source • Tests • Documentation • Based on goals • compile, test, package, install, deploy, site… • Just learn the conventions! • Archetype plugin for easy project creation • mvn archetype:generate
  • 6. + Maven vs. ant or Gradle • Vs. ant • Standardizes project structure • Provides dependency management • Built-in reporting and documentation • Easier to setup platform independent projects • Vs. Gradle • More verbose project file (positive and negative) • Little to no programming knowledge needed • Large community support • Pre-built plugins, solutions and documentation • Better IDE support • Except Eclipse, which does not support either well
  • 7. + Basic Concepts • POM • Master & Effective • Lifecycles • Maven’s lifecycles • Goals • Plugins • Plugin Management • Dependencies • Profiles
  • 8. + POM • File defining project/module settings • XML file* • “Super POM” provided by Maven • Super POM used as base for all Maven projects • Built-in hierarchy • Settings, properties, plugins, dependencies, profiles… • Use mvn help:effective-pom to generate the “used” POM • Parent POM • POM files can be nested allowing each project to encapsulate the artifact’s intent • Defines base versions for common dependencies, reporting, profiles and plugins • One POM per module
  • 9. + POM – Important Attributes • <artifactId/> • <distributionManagement/> • Artifact’s name, must be unique • Controls where artifact is within groupID scope deployed to • <groupId/> • <parent/> • Typically package name for • Hierarchy of the project project • <version/> • <version/> • Current version of the artifact • Current version of the artifact • <scm/> • <name/> • Source code management • Name of the app, IDEs typically section use this • <dependencyManagement/> • <packaging/> • Defaults for dependencies • Type of artifact packaging • <dependencies/> • POM, jar, WAR, EAR, EJB, • Dependency definitions bundle
  • 10. + POM – Important Attributes <project …> <groupId>com.example</groupId> <artifactId>some-webapp</artifactId> <packaging>war</packaging> <version>0.01-SNAPSHOT</version> <name>${project.artifactId}</name> <distributionManagement> <snapshotRepository> <id>releases</id> <name>Mobile Snapshot Nexus</name> <url>http://nexus.kohls.com/content/repositories/Snapshots</url> </snapshotRepository> <repository> <id>releases</id> <name>Mobile Release Nexus</name> <url>http://nexus.kohls.com/content/repositories/releases</url> </repository> <site> <id>site-docs</id> <url>scp://${site.host}/opt/lampp/htdocs/site/${project.artifactId}</url> </site> </distributionManagement> </project>
  • 11. + Versioning • Versions should be considered permanent • SNAPSHOT builds should NEVER be deployed or released • 15 step process to determine which version build to use! • Maven Reactor – Maven’s process to determine which dependencies and versions are included • Initial sequence based versioning • 0 – for alpha • 1 – after first release • major (dot) minor • 1.1, 1.11, 1.111, 1.112 • Attempt to keep major versions should be same on each module • 10.2.17 – 10 = major number, 2 = internal major, 17 = release
  • 12. + Lifecycles • Phases maven moves to build artifact • Runs in sequential, pre-defined order • Ex: mvn clean site – runs clean and site • Note: site typically has surefire-plugin clean turned on, so phases in default are run • Ex: mvn clean test site - runs clean, everything in default up thru test and then site default • 3 Core Phases • clean • default site • site • Clean – resets project back to known state • Site – Builds documentation (“site docs”), reporting, JavaDocs, coverage, test results…
  • 13. + Default Phase • 23 sub-phases • Typically run unless only “clean” or “site” lifecycle run • “site” might include default-bound goals inside of “default” phase such as test, generate-sources and compile • Common default sub-phases • generate-sources • compile • test • package • install • deploy • Some phases have goals bound automatically • compile – compiler:compile
  • 14. + Commands • Goals – Represent specific task contributing to build phase in their lifecycle • Goals are bound to phases • Example goals: checkstyle:checkstyle • Plugins – Modules adding new goals to maven • Sample plugins • PMD • Checkstyle • JavaDocs • Resources (maven-resources) • Surefire and Failsafe
  • 15. + Dependency Management • Group <dependency> <groupId>com.example</groupId> • Artifact <artifactId>random-webapp</artifactId> <packaging>war</packaging> • Version <version>0.01</version> <scope>test</scope> • Scope </dependency> • Type • Exclusions • Optional • Quick note: Set dependency versions and exclusions in <dependencyManagement/>
  • 16. + Dependency Management – Scope • Scope • compile – Available in all classpaths, dependent projects inherit {default scope} • provided – Indicates that JDK or container will provide at run-time • runtime – Not required to compile, but needed to run • system – Same as provided, does not look up in repository • test – Available only during test phase • import – When type is POM, import dependencies matching in <dependencyManagement/> sections • Type • jar, pom, war, ear, ejb, bundle, maven-plugin • Default packaging "jar" • Exclusions • Optional
  • 17. + Dependency Management – cont. • Type – Specify type of artifact (common) • JAR – Default type • WAR – WAR, used for WAR Overlays and Uber WARs • POM – Master POM or dependency POMs • Exclusions – Ability to exclude dependencies from incoming dependencies {transitive dependencies} • Used to manage transitive dependencies • Optional – Method to mark transitive dependencies as excluded by default. Declared in incoming dependency, not in project • Note: Must repeat <scope> and <type> in dependency and dependencyManagement sections
  • 18. + Artifact Naming Conventions • Why have naming conventions? • Promotes re-use • Organizes artifacts • Libraries (jar type) • descriptive-name-lib • ex: common-database-lib • Webapps (ear and war) • descriptive-name-webapp • ex: company-ecommerce-webapp • Common dependencies • Groups of similar dependencies can be grouped into a “dependency project" • descriptive-name-dep • ex: common-web-dep
  • 19. + Repositories • Local – Local dependency cache • ~/.m2/repository • Remote – Servers that hold binaries • Internet (“central”) • Internal – Nexus, Artifactory… • Plugin and Dependency repositories defined in POM or settings.xml • NOTE: Best to define in settings.xml • Treat <id> as a “name” for the repository; should match <id> in all settings.xml files in each environment
  • 20. + Deployment • Single command to deploy • Pushes artifact to artifact server • (Almost) single command to Release • Release process consists of two goals • release:prepare • Strip “-SNAPSHOT” from <version/> • Run through site phase • SCM “tag” project (optional) • release:perform • Pushes artifact to artifact server • Increments <version/> number • Appends “-SNAPSHOT” to <version/> • Checks in (SCM) updated POM upon success
  • 21. + Deployment: Snapshot • Snapshot builds are incremental, non-versioned releases • Typically used for intra-team use • Use “deploy” to push snapshots to repository • Repository location must be setup to accept snapshots • Allow for redeploy • Allow for snapshots over releases • Make sure <server> setting is correct in settings.xml • Typical use case: • Setup a nightly SNAPSHOT build for external teams to use • Minimizes changes that might cause compilation failures
  • 22. + Q&A • Lots covered…questions?