Header Ad Section

Maven Basics

Maven is a commonly used Build and Dependancy Management tool. Firstly let's have a quick look at what are the Build and Dependancy Management Tools are.

Simply Build tools are programs which uses to automate the executable application creation from their source code (Eg:- .java for Java applications, .apk for Android applications etc.). Building process incorporates compiling, packaging, the code into a usable or executable form. 

Basically build automation is the process of scripting or automating a wide variety of tasks that software developers perform in their day to day activities such as:

  1. Downloading the necessary dependancies.
  2. Compiling the Source Code into Binary Code.
  3. Packaging that Binary Code.
  4. Running Tests.
  5. Deployment to QA, UAT, or Production Environments.
Simply, the advantage and the major purpose of using a build tool is, it hides all the low level tasks that the developer have to operate in order to perform the tasks above mentioned and simplify those tasks by handling and automating all low level tasks by the build tool itself.

For further details you may refer our Build and Dependancy Management Tools article for in-detailed information about Build and Dependancy Management Tools.

All the above mentioned tasks are done by Maven Plugins. In other words we can say that Maven is a plugin execution framework. So, let's have a look at the major Maven plugin types. 

Maven plugins can be mainly divided in to two major caregories by considering their duty. They are:

  1.     Build Plugins - Plugins which are related to the build process
  2.     Reporting Plugins - Plugins which are related to the reporting process

Build Plugins

Build Plugins will be executed during the build and they should be configured in the <build/> element from the POM file.

Reporting Plugins

Reporting Plugins will be executed during the site generation and they should be configured in the  <reporting/> element from the POM file. Because the result of a Reporting plugin is part of the generated site, reporting plugins should be both internationalised and localised.


What is POM? 

Simply POM stands for Project Object Model. It is the fundamental unit of work in Maven. POM is an XML file that contains information about project dependancies and it's configuration details used by maven to build the Project. When executing a task or a goal, Maven firstly dig in to the POM in the current directory and it reads the POM and gets the relevant configuration informations and then executes the goal.

Furthermore, Maven plugins can be divided into four sub categories by considering their plugin category.

  1. Maven Core Plugins
  2. Maven Reporting Plugins
  3. Maven Packaging Types
  4. Maven Tools

Maven Core Plugins

Maven have introduced several core plugins to automate the building process. They are as below.

  1. clean - Clean up after the Build
  2. compiler - Compiles java Sources
  3. install - Install the built artefact to the local repository
  4. deploy - Deploys the built artefact to the remote repository
  5. failsafe - Run the Unit Integration tests in an isolated class loader
  6. resources - Copy the resources to the output directory for including in the JAR
  7. site - Generate a site for current project
  8. surefire - Run the Unit tests in an isolated class loader
  9. verifier - Useful for integration tests - verifies the existence of certain conditions

Maven Reporting Plugins

  1. changelog - Generates a list of recent changes from your SCM
  2. changes - Generates a report from an issue tracker or a change document
  3. checkstyle - Generates a Checkstyle report
  4. doap - Generates a Description of a Project (DOAP) file from a POM.
  5. docck - Documentation Checker plugin
  6. javadoc - Generates Javadoc for the project
  7. jdeps - Run JDK's JDeps tool on the project
  8. jxr - Generates a source cross reference 
  9. linkcheck - Generates a link check report for the project documentation
  10. pmd - Generates a PMD report
  11. project-info-reports - Generates standard project reports
  12. surfire-reports - Generates a report based on the results of the unit-tests

Maven Packaging Types 

Maven have introduced several packaging types to wrap up the output as a given packaging format.

  1. ear - Generates an EAR from the current project
  2. ejb - Build an EJB (Enterprise Java Beans) (an optional client) from the current project
  3. jar - Build a JAR from the current project
  4. rar - Build a RAR from the current project
  5. war - Build a WAR from the current project
  6. app-client/acr - Build a JavaEE application client form the current project
  7. shade - Build asn Uber-JAR from current project including dependancies
  8. source - Build a source-JAR from the current project
  9. jlink - Build a Java Runtime Image
  10. jmod - Build Java JMod Files

Maven Tools

  1. antrun - Run a set of ant tasks from a phase of the build
  2. artifact - Manage artifacts tasks such as build info 
  3. archetype - Generates a Skelton project structure from an archetype
  4. assembly - Build an assembly (distribution) of sources and/or binaries
  5. dependancy - Dependancy manipulation (copy, unpack) and analysis
  6. gpg - Creates signatures for the artefacts and POMs
  7. help - Get information about the working environment for the project
  8. invoker - Run a set of maven projects and and verify the output
  9. jarsigner - Signs or verify the project artifacts
  10. patch - Use the gnu patch tool to apply patch files to the source code
  11. pdf - Generates a PDF version of the project's documentation
  12. plugin - Creates a Maven plugin descriptor for any mojos found in the source tree, to include in the JAR.
  13. release - Release the current project - Updating the POM and tagging in the SCM
  14. scm - Execute SCM commands for the current project
  15. scm-publish - Publish your maven website to a SCM location
  16. scripting - The Maven Scripting Plugin wraps the Scripting API according to JSR223
  17. stage - Assists with release staging and promotion
  18. tool chains - Allows to share configuration across plugins





Buy website traffic cheap

Post a Comment

0Comments