SlideShare una empresa de Scribd logo
1 de 45
Descargar para leer sin conexión
Build Automation With maven
(By Ankit Gubrani)
Agenda
q What is maven?
q Why maven?
q Maven Installation.
q How maven works.
q The build Lifecycle.
q Basics of POM, Profiles, Repositories.
q Maven Plugins.
q Maven Dependency.
q Creating custom maven Plugin.
What is maven ?
Any Idea?
Ok but before that !
What is a build tool?
Build Tool
q A build tool is a programming utility that is used when
building a new version of a program.
q Build tools are tools to manage and organise your
builds.
Now that you know What Build Tool is.
Here is Maven -
Maven
q Maven is a popular open source build tool used primarily
for Java projects. It was designed to make build
process easier task.
q Apart from being a build tool Maven can also manage
reporting and documentation from a central piece of
information.
q It is based on the concept of a project object model
(POM).
q Maven is more than just a "build tool" rather is a
project management tool.
Maven provides developers ways to manage following:
q Builds
q Documentation
q Reporting
q Dependencies
q SCMs
q Releases
q Distribution
q Mailing list
Why Maven if we have other Build tools
available ???
Comparison
Here are some of the benefits of using Maven over any
other build (Ant, make etc) :
q Standardized project layout. (Convention over
configuration unlike ANT)
q Automatic dependency handling.(Ant can't do this
unassisted)
q Large Existing repository.
q Reusability ( through Maven Plugins).
Maven Installation
Installation
q Maven is a Java tool, so you must have Java installed in
order to proceed.
q Follow the instructions on the link for intallation :
http://maven.apache.org/download.cgi#Installatio
n
q Once installation is done type the following command in
a terminal or in a command prompt:
mvn –version
It should print out your installed version of Maven
Maven Build Lifecycle
Lifecycle
q Build Lifecycle is a well defined sequence of phases
which define the order in which the goals are to be
executed. Here phase represents a stage in life cycle.
q When Maven starts building a project, it steps through
a defined sequence of phases and executes goals which
are registered with each phase. Maven has following
three standard lifecycles:
q Clean
q default(or build)
q Site
q A Build Lifecycle is Made Up of Phases.
q A Build Phase is Made Up of Plugin Goals.
q A Plugin Goal represents a specific task (finer than a
build phase) which contributes to the building and
managing of a project.
lPhase-Goal Binding
lLifecycle-Phase Binding
POM
lProject Object Model
q POM stands for Project Object Model. It is
fundamental Unit of work in Maven.
q It is an XML file. It always resides in the base
directory of the project as pom.xml.
q The POM contains information about the project and
various configuration detail used by Maven to build the
project.
lSome of the configuration that can be specified in the
POM are following:
q project dependencies
q plugins
q goals
q build profiles
q project version
q developers
q mailing list
Maven Repository
q A maven repository is a directory of packaged JAR file with
pom.xml file. Maven searches for dependencies in the
repositories. There are 3 types of maven repostory :
§ Local Repository
§ Central Repository
§ Remote Repository
q Maven searches for the dependencies in the following order:
q Local repository then Central repository then Remote
repository.
q Local Repository :-
§ Maven local repository is located in your local
system. It is created by the maven when you run
any maven command.
§ By default, maven local repository is
%USER_HOME%/.m2 directory. For example:
C:UsersSSS IT.m2.
q Central Repository :-
§ Maven central repository is located on the web. It
has been created by the apache maven community
itself.
§ The path of central repository is:
http://repo1.maven.org/maven2 .
q Remote Repository :-
§ Maven remote repository is located on the web.
Most of libraries can be missing from the central
repository such as JBoss library etc, so we need to
define remote repository in pom.xml file.
Build Profile
q A Build profile is a set of configuration values which can be
used to set or override default values of Maven build. Using
a build profile, you can customize build for different
environments such as Production v/s Development
environments.
q Build profiles are majorly of three types :
§ Per Project :- Defined in the project POM file, pom.xml
§ Per User :- Defined in Maven settings xml file
(%USER_HOME%/.m2/settings.xml)
§ Global :- Defined in Maven global settings xml file
(%M2_HOME%/conf/settings.xml)
Maven Plugins
q Plugins are the central feature of Maven that allow for the
reuse of common build logic across multiple projects.
q Maven is actually a plugin execution framework where every
task is actually done by plugins.
q A plugin generally provides a set of goals and which can be
executed using following syntax:
ü mvn [plugin-name]:[goal-name]
q There are plugins for almost every task in maven like plugins
are used to: create jar files, create war files, compile code,
unit test code, create project documentation, and on and on.
q Maven provides following two types of Plugins:
1)Build plugins:- They execute during the build and should be
configured in the <build/> element of pom.xml .
2)Reporting plugins:-They execute during the site
generation and they should be configured in the
<reporting/> element of the pom.xml .
Archetype
lAn archetype is defined as an original pattern or model from
which all other things of the same kind are made.
lMaven provides users,a very large list of different types of
project templates using concept of Archetype. Maven helps
users to quickly start a new java project using following
command :
mvn archetype:generate
lArchetype is a Maven plugin whose task is to create a project
structure as per its template. Archetype Plugin allows the user
to create a Maven project from an existing template called an
archetype.
Archetype
Now that you know basics of maven,
Let's create a maven project
q For creating any project maven provides templates(Archetype),
using which one can create by selecting any one archetype from
available archetypes.
q To start a new Maven project, use the Maven Archetype plugin from
the command line. Run the following command :-
§ mvn archetype:generate -DarchetypeGroupId=[Group Id] -
DarchetypeArtifactId= [Artifact ID]
q You can search for all archetypes provided by maven at there
central repository (http://search.maven.org/) and all other 3rd
party archetypes at any remote repository like -
http://mvnrepository.com
Demo
Maven Snapshots
q SNAPSHOT is a special version that indicates a current
development copy.
q Unlike regular versions, Maven checks for a new
SNAPSHOT version in a remote repository for every build.
q Snapshot vs Version :-
q In case of Version, if Maven once downloaded the mentioned
version say data-service:1.0, it will never try to download a
newer 1.0 available in repository. To download the updated
code, artifact version is be upgraded to 1.1.
q In case of SNAPSHOT, Maven will automatically fetch the
latest SNAPSHOT (data-service:1.0-SNAPSHOT)
everytime app-ui team build their project.
Hey did you notice ???
What we did till now automated the build
process. And this is called Build
Automation using Maven
Auto-Generated Project Documentation
Using maven
q Team communication is an essential part of any
project. And wasting time looking for technical project
information can be costly and frustrating. Clearly, any
IT project will benefit from having its own dedicated
technical Website.
q That's where the Maven site generator steps in. With
little effort, you can have a professional-quality, low
maintenance project Website up and running in no time.
q Documentation is generated by running
§ mvn site
Any Questions ?
lAbout Me
.about-me{
name: Ankit Gubrani !Sr. AEM Developer;
email-id: ankit.gubrani@codebrains.co.in;
LinkedIn: in.linkedin.com/in/ankitgubrani;
twitter: @ankitgubrani90;
blog: codebrains.blogspot.in;
website : codebrains.co.in;
}
Thank You
Please contact me at : ankit.gubrani@codebrains.co.in

Más contenido relacionado

La actualidad más candente

What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
Simplilearn
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to Maven
Vadym Lotar
 

La actualidad más candente (20)

Jenkins
JenkinsJenkins
Jenkins
 
Jenkins presentation
Jenkins presentationJenkins presentation
Jenkins presentation
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
Apache Maven
Apache MavenApache Maven
Apache Maven
 
Jenkins Introduction
Jenkins IntroductionJenkins Introduction
Jenkins Introduction
 
Jenkins CI
Jenkins CIJenkins CI
Jenkins CI
 
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
 
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
 
Maven
MavenMaven
Maven
 
Continuous delivery-with-maven
Continuous delivery-with-mavenContinuous delivery-with-maven
Continuous delivery-with-maven
 
Dev ops using Jenkins
Dev ops using JenkinsDev ops using Jenkins
Dev ops using Jenkins
 
Jenkins tutorial for beginners
Jenkins tutorial for beginnersJenkins tutorial for beginners
Jenkins tutorial for beginners
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines
 
Introduction to jenkins
Introduction to jenkinsIntroduction to jenkins
Introduction to jenkins
 
Automated Web Testing Using Selenium
Automated Web Testing Using SeleniumAutomated Web Testing Using Selenium
Automated Web Testing Using Selenium
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to Maven
 
Automated testing using Selenium & NUnit
Automated testing using Selenium & NUnitAutomated testing using Selenium & NUnit
Automated testing using Selenium & NUnit
 
Hybrid framework
Hybrid frameworkHybrid framework
Hybrid framework
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to Maven
 
Introduction to CICD
Introduction to CICDIntroduction to CICD
Introduction to CICD
 

Destacado

Version Management in Maven
Version Management in MavenVersion Management in Maven
Version Management in Maven
Geert Pante
 
Continuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenContinuous Deployment Pipeline with maven
Continuous Deployment Pipeline with maven
Alan Parkinson
 

Destacado (20)

Apache Maven
Apache MavenApache Maven
Apache Maven
 
Version Management in Maven
Version Management in MavenVersion Management in Maven
Version Management in Maven
 
Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
 
Automated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yardsAutomated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yards
 
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
 
Continuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenContinuous Deployment Pipeline with maven
Continuous Deployment Pipeline with maven
 
Apache maven 2 overview
Apache maven 2 overviewApache maven 2 overview
Apache maven 2 overview
 
Tech Talk #5 : Code Analysis SonarQube - Lương Trọng Nghĩa
Tech Talk #5 : Code Analysis SonarQube - Lương Trọng NghĩaTech Talk #5 : Code Analysis SonarQube - Lương Trọng Nghĩa
Tech Talk #5 : Code Analysis SonarQube - Lương Trọng Nghĩa
 
Maven overview
Maven overviewMaven overview
Maven overview
 
Maven
Maven Maven
Maven
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
 
Hibernate 3
Hibernate 3Hibernate 3
Hibernate 3
 
Selenium Test Automation
Selenium Test AutomationSelenium Test Automation
Selenium Test Automation
 
Hibernate
HibernateHibernate
Hibernate
 
Maven and ANT
Maven and ANTMaven and ANT
Maven and ANT
 
Mastering Maven 2.0 In 1 Hour V1.3
Mastering Maven 2.0 In 1 Hour V1.3Mastering Maven 2.0 In 1 Hour V1.3
Mastering Maven 2.0 In 1 Hour V1.3
 
Continuous integration and delivery for java based web applications
Continuous integration and delivery for java based web applicationsContinuous integration and delivery for java based web applications
Continuous integration and delivery for java based web applications
 
Continuous Delivery
Continuous DeliveryContinuous Delivery
Continuous Delivery
 
Intro To Hibernate
Intro To HibernateIntro To Hibernate
Intro To Hibernate
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVC
 

Similar a Build Automation using Maven

Apache maven, a software project management tool
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management tool
Renato Primavera
 

Similar a Build Automation using Maven (20)

Maven
MavenMaven
Maven
 
Introduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS worldIntroduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS world
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1
 
Apache maven, a software project management tool
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management tool
 
Maven 2 features
Maven 2 featuresMaven 2 features
Maven 2 features
 
Maven basics
Maven basicsMaven basics
Maven basics
 
Manen Ant SVN
Manen Ant SVNManen Ant SVN
Manen Ant SVN
 
Maven
MavenMaven
Maven
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
 
Open Source tools overview
Open Source tools overviewOpen Source tools overview
Open Source tools overview
 
Apache ANT vs Apache Maven
Apache ANT vs Apache MavenApache ANT vs Apache Maven
Apache ANT vs Apache Maven
 
Maven in mulesoft
Maven in mulesoftMaven in mulesoft
Maven in mulesoft
 
Maven
MavenMaven
Maven
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svn
 
Mavennotes.pdf
Mavennotes.pdfMavennotes.pdf
Mavennotes.pdf
 
A-Z_Maven.pdf
A-Z_Maven.pdfA-Z_Maven.pdf
A-Z_Maven.pdf
 
Session 2
Session 2Session 2
Session 2
 
Session 2
Session 2Session 2
Session 2
 
Exploring Maven SVN GIT
Exploring Maven SVN GITExploring Maven SVN GIT
Exploring Maven SVN GIT
 
Apache_Maven
Apache_MavenApache_Maven
Apache_Maven
 

Más de Ankit Gubrani

Más de Ankit Gubrani (8)

Sling pipes
Sling pipesSling pipes
Sling pipes
 
Circuit breaker pattern
Circuit breaker patternCircuit breaker pattern
Circuit breaker pattern
 
Sling models
Sling modelsSling models
Sling models
 
AEM integration with Apache Mahout
AEM integration with Apache MahoutAEM integration with Apache Mahout
AEM integration with Apache Mahout
 
Content personalization in AEM
Content personalization in AEMContent personalization in AEM
Content personalization in AEM
 
Integrating Apache Wookie with AEM || AEM-Wookie Connector Tool
Integrating Apache Wookie with AEM || AEM-Wookie Connector ToolIntegrating Apache Wookie with AEM || AEM-Wookie Connector Tool
Integrating Apache Wookie with AEM || AEM-Wookie Connector Tool
 
Introduction to Sightly
Introduction to SightlyIntroduction to Sightly
Introduction to Sightly
 
AEM Client Context Customisation
AEM Client Context CustomisationAEM Client Context Customisation
AEM Client Context Customisation
 

Último

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Último (20)

%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 

Build Automation using Maven

  • 1. Build Automation With maven (By Ankit Gubrani)
  • 2. Agenda q What is maven? q Why maven? q Maven Installation. q How maven works. q The build Lifecycle. q Basics of POM, Profiles, Repositories. q Maven Plugins. q Maven Dependency. q Creating custom maven Plugin.
  • 5. Ok but before that ! What is a build tool?
  • 6. Build Tool q A build tool is a programming utility that is used when building a new version of a program. q Build tools are tools to manage and organise your builds.
  • 7.
  • 8. Now that you know What Build Tool is. Here is Maven -
  • 9. Maven q Maven is a popular open source build tool used primarily for Java projects. It was designed to make build process easier task. q Apart from being a build tool Maven can also manage reporting and documentation from a central piece of information. q It is based on the concept of a project object model (POM). q Maven is more than just a "build tool" rather is a project management tool.
  • 10. Maven provides developers ways to manage following: q Builds q Documentation q Reporting q Dependencies q SCMs q Releases q Distribution q Mailing list
  • 11. Why Maven if we have other Build tools available ???
  • 12. Comparison Here are some of the benefits of using Maven over any other build (Ant, make etc) : q Standardized project layout. (Convention over configuration unlike ANT) q Automatic dependency handling.(Ant can't do this unassisted) q Large Existing repository. q Reusability ( through Maven Plugins).
  • 14. Installation q Maven is a Java tool, so you must have Java installed in order to proceed. q Follow the instructions on the link for intallation : http://maven.apache.org/download.cgi#Installatio n q Once installation is done type the following command in a terminal or in a command prompt: mvn –version It should print out your installed version of Maven
  • 15.
  • 17. Lifecycle q Build Lifecycle is a well defined sequence of phases which define the order in which the goals are to be executed. Here phase represents a stage in life cycle. q When Maven starts building a project, it steps through a defined sequence of phases and executes goals which are registered with each phase. Maven has following three standard lifecycles: q Clean q default(or build) q Site
  • 18. q A Build Lifecycle is Made Up of Phases. q A Build Phase is Made Up of Plugin Goals. q A Plugin Goal represents a specific task (finer than a build phase) which contributes to the building and managing of a project.
  • 20. POM
  • 21. lProject Object Model q POM stands for Project Object Model. It is fundamental Unit of work in Maven. q It is an XML file. It always resides in the base directory of the project as pom.xml. q The POM contains information about the project and various configuration detail used by Maven to build the project.
  • 22. lSome of the configuration that can be specified in the POM are following: q project dependencies q plugins q goals q build profiles q project version q developers q mailing list
  • 24. q A maven repository is a directory of packaged JAR file with pom.xml file. Maven searches for dependencies in the repositories. There are 3 types of maven repostory : § Local Repository § Central Repository § Remote Repository q Maven searches for the dependencies in the following order: q Local repository then Central repository then Remote repository.
  • 25. q Local Repository :- § Maven local repository is located in your local system. It is created by the maven when you run any maven command. § By default, maven local repository is %USER_HOME%/.m2 directory. For example: C:UsersSSS IT.m2. q Central Repository :- § Maven central repository is located on the web. It has been created by the apache maven community itself. § The path of central repository is: http://repo1.maven.org/maven2 .
  • 26. q Remote Repository :- § Maven remote repository is located on the web. Most of libraries can be missing from the central repository such as JBoss library etc, so we need to define remote repository in pom.xml file.
  • 28. q A Build profile is a set of configuration values which can be used to set or override default values of Maven build. Using a build profile, you can customize build for different environments such as Production v/s Development environments. q Build profiles are majorly of three types : § Per Project :- Defined in the project POM file, pom.xml § Per User :- Defined in Maven settings xml file (%USER_HOME%/.m2/settings.xml) § Global :- Defined in Maven global settings xml file (%M2_HOME%/conf/settings.xml)
  • 30. q Plugins are the central feature of Maven that allow for the reuse of common build logic across multiple projects. q Maven is actually a plugin execution framework where every task is actually done by plugins. q A plugin generally provides a set of goals and which can be executed using following syntax: ü mvn [plugin-name]:[goal-name] q There are plugins for almost every task in maven like plugins are used to: create jar files, create war files, compile code, unit test code, create project documentation, and on and on.
  • 31. q Maven provides following two types of Plugins: 1)Build plugins:- They execute during the build and should be configured in the <build/> element of pom.xml . 2)Reporting plugins:-They execute during the site generation and they should be configured in the <reporting/> element of the pom.xml .
  • 33. lAn archetype is defined as an original pattern or model from which all other things of the same kind are made. lMaven provides users,a very large list of different types of project templates using concept of Archetype. Maven helps users to quickly start a new java project using following command : mvn archetype:generate lArchetype is a Maven plugin whose task is to create a project structure as per its template. Archetype Plugin allows the user to create a Maven project from an existing template called an archetype. Archetype
  • 34. Now that you know basics of maven, Let's create a maven project
  • 35. q For creating any project maven provides templates(Archetype), using which one can create by selecting any one archetype from available archetypes. q To start a new Maven project, use the Maven Archetype plugin from the command line. Run the following command :- § mvn archetype:generate -DarchetypeGroupId=[Group Id] - DarchetypeArtifactId= [Artifact ID] q You can search for all archetypes provided by maven at there central repository (http://search.maven.org/) and all other 3rd party archetypes at any remote repository like - http://mvnrepository.com
  • 36. Demo
  • 38. q SNAPSHOT is a special version that indicates a current development copy. q Unlike regular versions, Maven checks for a new SNAPSHOT version in a remote repository for every build. q Snapshot vs Version :- q In case of Version, if Maven once downloaded the mentioned version say data-service:1.0, it will never try to download a newer 1.0 available in repository. To download the updated code, artifact version is be upgraded to 1.1. q In case of SNAPSHOT, Maven will automatically fetch the latest SNAPSHOT (data-service:1.0-SNAPSHOT) everytime app-ui team build their project.
  • 39. Hey did you notice ??? What we did till now automated the build process. And this is called Build Automation using Maven
  • 41. q Team communication is an essential part of any project. And wasting time looking for technical project information can be costly and frustrating. Clearly, any IT project will benefit from having its own dedicated technical Website. q That's where the Maven site generator steps in. With little effort, you can have a professional-quality, low maintenance project Website up and running in no time. q Documentation is generated by running § mvn site
  • 43.
  • 44. lAbout Me .about-me{ name: Ankit Gubrani !Sr. AEM Developer; email-id: ankit.gubrani@codebrains.co.in; LinkedIn: in.linkedin.com/in/ankitgubrani; twitter: @ankitgubrani90; blog: codebrains.blogspot.in; website : codebrains.co.in; }
  • 45. Thank You Please contact me at : ankit.gubrani@codebrains.co.in