Maven - Maven Build Automation - maven tutorial

What is Build Automation?

  • Build automation is the process in which a project gets initiated with the build process.
  • Whenever a change is made in the workspace and also to ensure that project is stable along with its dependent projects (if the project is used by any other projects).
  • This is very much essential in the software development life cycle as it is difficult to manage with the failed builds during the development phase.
  • Hence, a process is required in order to ensure the health status of the build all the time and keep an eye on the same.
  • Consider the project JavaSamples in this scenario.
  • Here, lot of programs varying across different oops concept will be written and tested.
  • But, it is always difficult to test every class independently for the compilation issue since they are modularized under different set of packages.
  • In order to achieve this, maven provides a feature to automate the same.
  • Consider, developers want to check the build stability after each check in done to the project. Also, consider that this JavaSamples project is a dependent project of another project called CoreJavaTutorials.
  • Hence, it is mandatory to maintain a stable build of JavaSamples.
  • Below mentioned are the pom.xml files for two dependent projects.
maven tutorial tags : apache maven , maven repository , maven central

CoreJavawikitechy Project:

<project xmlns="" 
   <artifactId>CoreJavaTutorials </artifactId>

JavaSamples Project:

<project xmlns="" 
  • Now consider that there are some changes made on the JavaSamples project.
  • Developer need to update the pom.xml of the JavaSamples project by adding a post build goal on the same.
  • Post build goal is nothing but, a goal which defines a specific set of tasks once the build is successful. e.g. generating javadocs is a post build goal.

Sample Code:

<project xmlns="" 

Build Automation using Jenkins Server:

  • Jenkins Server is a continuous integration tool.
  • Using Jenkins build can be automated, tested for the health status of the builds and also multiple builds can be managed.
  • It is a handy tool which is easily available to download and very easy to set up.

Setting up Jenkins Server

  • Download the latest Jenkins.war from following link
 maven setting up jenkins server

learn maven tutorial - maven setting up jenkins server - maven example

  • Deploy the Jenkins.war file in the local web server of our machine. E.g. Tomcat
  • Start the server and open the browser and hit
 maven automation server

learn maven tutorial - maven automation server - maven example

Creating a new Job and Deploying the Build

  • Click on the Create new jobs link, shown in picture above, to configure a project for build automation. Enter the details of the project as shown below and click OK.
  • You must enter the Name and select the radio button for Maven Project.
 maven new bulid

learn maven tutorial - maven new bulid - maven example

  • In the next page, fill all the required details like - Description, Path of the project's pom.xml and other details and click save.
  • Please check the below picture for help. Fill all the information and click on SAVE
 maven textbulid save

learn maven tutorial - maven textbulid save - maven example

 maven fil -automation

learn maven tutorial - maven fil -automation - maven example

 fill information click save

learn maven tutorial - maven fill information click save - learn maven tutorial

  • A Project/Job is now created in Jenkins. As shown below :
 created jenkins buildnow

learn maven tutorial - created jenkins buildnow in maven - maven example

 maven jenkins build-history

learn maven tutorial - maven jenkins build-history - maven example

  • Click on the build number link and it opens up the build details. Click on the Console Output to see the logs of the build.
 jenkins module build

learn maven tutorial - jenkins module build in maven - maven example

 jenkins check the logs

learn maven tutorial - maven jenkins check the logs - maven example

 meaven build output

learn maven tutorial - meaven build - maven example

Wikitechy provides an indepth knowledge on the below maven tutorial items such as maven download , maven install , maven goals , maven build , maven commands , maven plugin , maven search , maven eclipse , maven deploy , eclipse maven , maven junit , maven java , hibernate maven , maven project , java maven , maven version , maven proxy , maven 2 , maven pom , maven eclipse plugin , maven java version , maven properties , maven install windows , how to create maven project in eclipse , eclipse maven plugin , maven dependencies , what is maven in java , maven apache , maven project structure , how to install maven in eclipse

Related Searches to Maven Build Automation