What is Apache Maven

·

·

What is Maven

Apache Maven is open source tool for building Java projects, distributing project and managing them. It can compile source file, execute unit tests as well as assemble artifacts. In facts it is a successor of ant, more like a replacement of ant with additional capability. It makes use of POM (project Object Model) file which contains plugins and dependencies. Plugins says how a project should be built and dependencies says what are the required libraries it needs to perform the build. Maven is also sometimes called project management tools and the reason is that Maven can not only build, run junt test, deliver artifcats but is also is capable of running reports, generate a web site and communicating things between members.

What is a POM (project Object Model) File:

The POM file is the core file of any of a project in Maven’s World and It contains the most of information required to build any project in way you want the project to be built.

What have we learned till now:

Maven is a java tool to build any Java Project and it works off of POM file configuration. Yes you guessed it right, it works of Convention over configuration.

Build LifeCycle of Maven

  • validate : Validates project/s define in POM file is correct and all information needed are avialable.
  • compile : Simple as word complies, it compiles the project/s source listed in the POM.
  • test : Test the code using JUnit before packinging or being deployed.
  • package : Complied Classes are packaged in .JARs, .WARs and .EAR
  • integration-test : Runs the integration test to make sure the project runs fine.
  • verify : Runs the integration test result to make sure quality is met.
  • install : Install the generated package in the local repo for depedency validation
  • deploy : publishes the artifacts for the project/s with other developers
  • clean : Cleans the project
  • Generate site documentation of the project :
  • Full list of LifeCycle can be found here

Above LifeCycle are just some of them and let me tell you this, we should not worry about the lifecycle so much unless you are trying to customize the Maven’s default lifecycle. Yes you got the clue, we can customize Maven default life cycle as well as required but if we don’t it will simple do it’s job. it will read the default lifecycle from components.xml for Maven 2.x and default-bindings.xml for Maven 3.z

Why use Maven for your project

Just because everyone is talking about Maven and it’s a must have skills and i need to know it because i will be asked in interview are not just ddriving factors of why you should use Maven. In facts there are some of the stong driving facts that will make you do so.

Convention Over Configuration

Convention Over Configuration is a design pattern that just says, tell me what you need and i will get you what you want. Example, if you specify velocity template as dependency in the POM file dependency section, it will pull those dependecy and make your application work. You don’t have to download that dependency and configure it in your application, Maven will do it for you.

To Be Continued