POKE ME for any consultancy

Tuesday, December 22, 2015

Difference between Ant and Maven

Ant and Maven are different building tools in Java. Both the tools are considered good but with slight differences.


ANT full form is Another Needed Tool. Ant is a build tool that is java based. A build tool performs the following tasks:


  • Compiling java code into byte code
  • Placing this byte code in a package
  • Deployment to production systems
  • Document creation and release notes preparation.

Before start using ANT, we should be clear about the project name and the .java files and most importantly, the path where the .class files are to be placed.

How to use Maven
Refer: http://www.javatpoint.com/maven-repository and http://mvnrepository.com/
http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

  • Repeatable builds: if you can build the project, your colleagues will always be able to on their machines. It'll also be repeatable on the build server.
  • Standardization of the build system: new developers who understad Maven will instantly know how to build, release, test etc, removing a lot of learning overhead.
  • Focus on automation: Maven puts you in a mindset of automating processes around your software development.
  • Convention over configuration: no setup or minimal configuration required to build artifacts.
  • Dependency management: Maven will resolve and manage your dependencies for you.
  • Testing: the ability to run tests and integration tests as part of your project life cycle.
  • Plugins: there are thousands of plugins to carry out various tasks. These are simply configured in just by adding a reference into the POM.



The great advantage of using Maven is its repository infrastructure. This promotes standard protocols for the sharing of 3rd party libraries and enables teams to collaborate more effectively without being forced to check everything into the same source code repository (Modular builds).
Repository managers are freely available and I'd recommend installing one of the following:
  • Nexus
  • Artifactory
  • Archiva

Maven pom.xml file:

POM is an acronym for Project Object Model. The pom.xml file contains information of project and configuration information for the maven to build the project such as dependencies, build directory, source directory, test source directory, plugin, goals etc.


Element
Description
projectIt is the root element of pom.xml file.
modelVersionIt is the sub element of project. It specifies the modelVersion. It should be set to 4.0.0.
groupIdIt is the sub element of project. It specifies the id for the project group.
artifactIdIt is the sub element of project. It specifies the id for the artifact (project). An artifact is something that is either produced or used by a project. Examples of artifacts produced by Maven for a project include: JARs, source and binary distributions, and WARs.
versionIt is the sub element of project. It specifies the version of the artifact under given group.

No comments:

Post a Comment