Technology always grows and we always face problems with the old or conventional tools/technology. As a result we always keep on developing the new tools for new solution. in this article we will discuss about the build tool in java and their evolution.
The first popular build tool in java was Ant. Ant provides following features.
- Ant was a good build tool at that time and was easy to learn because it is using conventional approach and xml based script.
- Ant has xml based configuration of the build where you can write your own logic to the target to execute.
- After initial release ant provide the functionality to use plugin to make the build better. you can also write your own ant plugin.
- Ant doesn’t have the dependency management, but later on ant acheive this feature using Apache Ivy.
Ant has some drawbacks because of that the build evolution went to thte next level. the drawbacks are
- Ant is not modular approach of build.
- Ant doesn’t have dependency management and release management. later on we can acheive the dependency managemnt using integrate with apache Ivy and witer your own logic for release management.
- problems with continuous integration and other tool integration.
The second build tool (Maven) was developed to overcome the issue with ant. Most of the projects in these days are build with maven. Maven has its own feature
- Maven provides a standard way of building projects as maven has its own lifecycle.
- Maven provides a standard directory structure for any kind of projects.
- Maven provides the most important thing dependency and release management. maven uses the maven repository to download dependency. And maven release publish the artifacts to the respective repository.
- On top of that if you want to write your own logic to build, you can develope a maven plugin and use it in your build script.
- Maven has a good support of continuous integration.
- You can design your project in a modular approach with maven.
As of now there are no but less problems with maven but has.
- The xml build script is still structred way of writing the script but these days DSL(Domain specific language) specific build is a need of domain specific language projects.
- The xml script for build will be big and may be unmanageable for big projects.
- If you have multi-languge project then there will be a problem with mavan build.
The domain specific build is provided by Gradle. This is the new build tool and has all the features of Ant and Maven.
- Gradle don’t use xml for build script. it uses the groovy that’s why Gradle build scripts tend to be much shorter and clearer than those written for Ant or Maven.
- Gradle detects dependencies between projects and JARs.
- In Gradle you can define dependencies between projects on the local file system without publishing the artifacts for each to a repository.
- Initially gradle useed apache Ivy for dependency management but now it has own dependency management module. gralde uses the maven repository to download dependency.
- Gradle has best support for continuous integration and other tools.
- Gradle support multiple languagaes build and platforms including Java, Scala, Android, C/C++, and Groovy.
- It has the build flexibility like ant and lifecycle management like maven.
- Google use Gradle for official android build. and there are other frameworks spring, hibernate is also using gradle build.
Disadvantage:
- Initially there is a learning curve but once you learn the build script will be much easier and cleaner.
In the next post we will develop a sample java project using Gradle.
Reference : Gradle.org
The post Evolution of java build (Ant, Maven, Gradle) appeared first on CodingLoading.