DevOps : Maven introduction

 

“Maven is a project management tool which encompasses a project object model, a set of standards, a project lifecycle, a dependency management system, and logic for executing plugin goals at defined phases in a lifecycle”

 

Maven is a build tool based on JAVA Files.

 

Main Features:

  • Build-tool
  • Dependencies management tool
  • Documentation tool

Maven Life Cycle:

 

  • Generate Resources
  • Compile
  • Test
  • Package
  • Install
  • Deploy

 

  • Generate Resources :
  • Compile: It is a phase where it will compile all java files will be converted to object files.
  • Test: Maven will try to do Unit Test i.e., a particular test what developer does to check if the code is running fine.
    During test it will create a “test.Java” file and the compiles to “test.class” file then the test is done.
  • Package: Is a assembly step where it create a deliverable file.
    e., Jar,war,ear files.
  • Install : It will take a copy of project output & copies into the local repository.
  • Deploy : Taking the deliverable of a project and put into some particular location.

 

 

Environmental Variables:

Before using maven there has to be few environmental Variables that has to be set, which can be seen in below picture.

 

 

 

 

  • We will have all the source file related to project in POM.XML.
  • Anything that we are going to specify in Maven will be provided through Goals.
    these goals will invoke a plugin, then the plugin will run the task.
  • Each and maven project should have a minimum of one POM.XML.
  • XML should have
    • G – Group ID
    • A – Artifact ID
    • V – Version ID
  • Source Code location
  • Specify certain plugin used in project
  • Dependencies
  • Xml should always begin with tag <project> and end with </project>
  • There are two types of plugins:
    • Build Plugin : using which we will do build activity (ex : install)
    • Reporting Plugin: Any plugin used to generate reports (ex: Site)

 

Default POM.XML:

 

 

Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (16 votes, average: 4.81 out of 5)
Loading...

13 thoughts on “DevOps : Maven introduction

Add Comment