Maven 3 Overview

Mike Ensor
Mike EnsorPractice Director of Digital Transformation Services em Dev9
+




    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?
1 de 22

Recomendados

Introduction to MavenIntroduction to Maven
Introduction to MavenMindfire Solutions
954 visualizações22 slides
Maven tutorialMaven tutorial
Maven tutorialDragos Balan
1.8K visualizações52 slides
Maven IntroductionMaven Introduction
Maven IntroductionSandeep Chawla
21.1K visualizações31 slides
Maven OverviewMaven Overview
Maven OverviewFastConnect
8.4K visualizações29 slides
Apache MavenApache Maven
Apache MavenRahul Tanwani
2.1K visualizações35 slides
Spring BootSpring Boot
Spring BootJaran Flaath
540 visualizações51 slides

Mais conteúdo relacionado

Mais procurados

Spring CoreSpring Core
Spring CorePushan Bhattacharya
7.3K visualizações48 slides
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework Serhat Can
25.9K visualizações52 slides
Maven pptMaven ppt
Maven pptnatashasweety7
4.6K visualizações21 slides
Gradle IntroductionGradle Introduction
Gradle IntroductionDmitry Buzdin
7.8K visualizações39 slides
Spring bootSpring boot
Spring bootGyanendra Yadav
1.9K visualizações32 slides
Spring boot IntroductionSpring boot Introduction
Spring boot IntroductionJeevesh Pandey
3K visualizações26 slides

Mais procurados(20)

Spring CoreSpring Core
Spring Core
Pushan Bhattacharya7.3K visualizações
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Serhat Can25.9K visualizações
Maven pptMaven ppt
Maven ppt
natashasweety74.6K visualizações
Gradle IntroductionGradle Introduction
Gradle Introduction
Dmitry Buzdin7.8K visualizações
Spring bootSpring boot
Spring boot
Gyanendra Yadav1.9K visualizações
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
Jeevesh Pandey3K visualizações
Spring bootSpring boot
Spring boot
sdeeg26.6K visualizações
MavenMaven
Maven
Vineela Madarapu979 visualizações
Spring annotationSpring annotation
Spring annotation
Rajiv Srivastava3K visualizações
An Introduction to MavenAn Introduction to Maven
An Introduction to Maven
Vadym Lotar13.9K visualizações
Java Spring FrameworkJava Spring Framework
Java Spring Framework
Mehul Jariwala2.9K visualizações
Introduction to flutter's basic conceptsIntroduction to flutter's basic concepts
Introduction to flutter's basic concepts
Kumaresh Chandra Baruri159 visualizações
Spring Framework  Spring Framework
Spring Framework
tola991.2K visualizações
Introduction to JavaIntroduction to Java
Introduction to Java
Professional Guru1.6K visualizações
Migrating to Java 11Migrating to Java 11
Migrating to Java 11
Arto Santala2.1K visualizações
Introduction to MavenIntroduction to Maven
Introduction to Maven
Onkar Deshpande3.4K visualizações
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBoot
Josué Neis696 visualizações
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
Guo Albert29.4K visualizações
Spring BootSpring Boot
Spring Boot
koppenolski363 visualizações
Apache maven 2 overviewApache maven 2 overview
Apache maven 2 overview
Return on Intelligence1.8K visualizações

Destaque

Maven for DummiesMaven for Dummies
Maven for DummiesTomer Gabel
6.3K visualizações9 slides
Demystifying MavenDemystifying Maven
Demystifying MavenMike Desjardins
4.9K visualizações88 slides
MavenMaven
MavenChris Roeder
2.3K visualizações34 slides
MavenMaven
Mavenfeng lee
1.8K visualizações33 slides
An introduction to MavenAn introduction to Maven
An introduction to MavenJoao Pereira
7.8K visualizações78 slides
Apache Maven for AT/QCApache Maven for AT/QC
Apache Maven for AT/QCVolodymyr Ostapiv
922 visualizações36 slides

Destaque(20)

Maven for DummiesMaven for Dummies
Maven for Dummies
Tomer Gabel6.3K visualizações
Demystifying MavenDemystifying Maven
Demystifying Maven
Mike Desjardins4.9K visualizações
MavenMaven
Maven
Chris Roeder2.3K visualizações
MavenMaven
Maven
feng lee1.8K visualizações
An introduction to MavenAn introduction to Maven
An introduction to Maven
Joao Pereira7.8K visualizações
Apache Maven for AT/QCApache Maven for AT/QC
Apache Maven for AT/QC
Volodymyr Ostapiv922 visualizações
Continuous delivery-with-mavenContinuous delivery-with-maven
Continuous delivery-with-maven
John Ferguson Smart Limited60.3K visualizações
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
boyw1652.6K visualizações
Git branching modelGit branching model
Git branching model
Gian Maria Ricci675 visualizações
Continuous inspection with SonarContinuous inspection with Sonar
Continuous inspection with Sonar
gaudol2.3K visualizações
Git Branching ModelGit Branching Model
Git Branching Model
Harun Yardımcı3.1K visualizações
Maven tutorial for beginnersMaven tutorial for beginners
Maven tutorial for beginners
inTwentyEight Minutes307 visualizações
Fundamental of apache mavenFundamental of apache maven
Fundamental of apache maven
Rajesh Kumar1.3K visualizações
MTN 4 1 09MTN 4 1 09
MTN 4 1 09
Tenn Coupons1.7K visualizações
Jornal O Engenheiro - Alexsandro Teixeira RibeiroJornal O Engenheiro - Alexsandro Teixeira Ribeiro
Jornal O Engenheiro - Alexsandro Teixeira Ribeiro
Alexsandro Teixeira Ribeiro1.1K visualizações
Carat.quimicaCarat.quimica
Carat.quimica
Liliana Sarango928 visualizações
Mefe tv. el valor de la planificaciónMefe tv. el valor de la planificación
Mefe tv. el valor de la planificación
comms planning1.1K visualizações
Tim Dean Producer ResumeTim Dean Producer Resume
Tim Dean Producer Resume
Timothy Dean432 visualizações

Similar a Maven 3 Overview

4 maven junit4 maven junit
4 maven junitHonnix Liang
692 visualizações43 slides
Practical maven-slides 2Practical maven-slides 2
Practical maven-slides 2Will Iverson
2.4K visualizações16 slides
Introduction tomavenIntroduction tomaven
Introduction tomavenManav Prasad
236 visualizações27 slides
Introduction in Apache Maven2Introduction in Apache Maven2
Introduction in Apache Maven2Heiko Scherrer
870 visualizações40 slides

Similar a Maven 3 Overview(20)

4 maven junit4 maven junit
4 maven junit
Honnix Liang692 visualizações
Practical maven-slides 2Practical maven-slides 2
Practical maven-slides 2
Will Iverson2.4K visualizações
Introduction tomavenIntroduction tomaven
Introduction tomaven
Manav Prasad236 visualizações
Lorraine JUG (1st June, 2010) - MavenLorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - Maven
Arnaud Héritier1.1K visualizações
Introduction in Apache Maven2Introduction in Apache Maven2
Introduction in Apache Maven2
Heiko Scherrer870 visualizações
Intro to Maven.pptIntro to Maven.ppt
Intro to Maven.ppt
MohammadSamiuddin124 visualizações
Apache Maven - eXo TN presentationApache Maven - eXo TN presentation
Apache Maven - eXo TN presentation
Arnaud Héritier915 visualizações
S/W Design and Modularity using MavenS/W Design and Modularity using Maven
S/W Design and Modularity using Maven
Scheidt & Bachmann2.9K visualizações
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svn
Ankur Goyal2.2K visualizações
Learning Maven by ExampleLearning Maven by Example
Learning Maven by Example
Hsi-Kai Wang1.6K visualizações
Introduction to mavenIntroduction to maven
Introduction to maven
Manos Georgopoulos1.2K visualizações
MavenMaven
Maven
Jyothi Malapati514 visualizações
MavenMaven
Maven
Jyothi Malapati1.7K visualizações
Developing Liferay Plugins with MavenDeveloping Liferay Plugins with Maven
Developing Liferay Plugins with Maven
Mika Koivisto11.7K visualizações
Mavennotes.pdfMavennotes.pdf
Mavennotes.pdf
AnkurSingh6567489 visualizações
Jenkins advance topicJenkins advance topic
Jenkins advance topic
Gourav Varma182 visualizações
Apache MavenApache Maven
Apache Maven
venkatraghavang461 visualizações
Session 2Session 2
Session 2
gayathiry167 visualizações
Session 2Session 2
Session 2
gayathiry162 visualizações

Último(20)

Java Platform Approach 1.0 - Picnic MeetupJava Platform Approach 1.0 - Picnic Meetup
Java Platform Approach 1.0 - Picnic Meetup
Rick Ossendrijver23 visualizações
.conf Go 2023 - SIEM project @ SNF.conf Go 2023 - SIEM project @ SNF
.conf Go 2023 - SIEM project @ SNF
Splunk163 visualizações
Spesifikasi Lengkap ASUS Vivobook Go 14Spesifikasi Lengkap ASUS Vivobook Go 14
Spesifikasi Lengkap ASUS Vivobook Go 14
Dot Semarang34 visualizações
CXL at OCPCXL at OCP
CXL at OCP
CXL Forum183 visualizações
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
Eleanor McHugh34 visualizações
Java 21 and Beyond- A Roadmap of Innovations  .pdfJava 21 and Beyond- A Roadmap of Innovations  .pdf
Java 21 and Beyond- A Roadmap of Innovations .pdf
Ana-Maria Mihalceanu51 visualizações
Web Dev - 1 PPT.pdfWeb Dev - 1 PPT.pdf
Web Dev - 1 PPT.pdf
gdsczhcet48 visualizações
PyCon ID 2023 - Ridwan Fadjar Septian.pdfPyCon ID 2023 - Ridwan Fadjar Septian.pdf
PyCon ID 2023 - Ridwan Fadjar Septian.pdf
Ridwan Fadjar163 visualizações
Liqid: Composable CXL PreviewLiqid: Composable CXL Preview
Liqid: Composable CXL Preview
CXL Forum118 visualizações
TE Connectivity: Card Edge InterconnectsTE Connectivity: Card Edge Interconnects
TE Connectivity: Card Edge Interconnects
CXL Forum93 visualizações

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?