A simple guide to Build Tools
Build tool is a software that creates a executable or production ready version of your project.
A build tool does the work of compiling files, linking all the required libraries, solving and downloading dependencies and create one executable files, which can be deployed to run the program as it is meant to. It combines all the libraries and classes needed for the program to execute. It resolves the dependencies. It finds what programs and commands to be executed in which order. It also handles transitive dependencies.
Very first build tool for linux like systems was make. Before make, a developer had to build the program manually, creating sequence of commands that builds one executable file. Make was build for unix like systems.
Java ecosystem has mainly three build tools.
- Ant
- Maven
- Gradle
They are platform agnostic, meaning works well on any operating system like windows, mac or linux.
Ant(another neat tool) was the first modern build tool. In it you have to specify the build script via XML files. It had low learning curve and good power to do tasks, but becomes unmanageable as the project grew as XML stores data in a hierarchical manner. Ant creates a build.xml file which contains all the information to convert the project into a executable file. Ant is very powerful tool, but you need to manually do everything which was not suitable for large projects.
Maven is a very popular java build tool. It created a concept of online repository called Maven Central. It contains all library and dependencies. A developer need not to download all libraries, he/she can only specify the dependency and Maven will automatically download required dependencies from maven central on the go. It also uses XML files for build configuration. Maven follows a standard format for specifying build configuration, which can be seen as both easiness or limitations. User can user do the pre specified tasks using the maven standards, but it does not provides much flexibility. It uses project object model(POM) files to maintain project. Maven has conflict resolution problems with different
Inspired by Maven, Ivy was introduced as a dependency manager for Ant. Ivy is a transitive dependency manager which works with Ant.
Gradle is a build tool that does not use XML for build script, instead it provides a domain specific language (DSL). This DSL is based on groovy, another JVM compatible language. Gradle provides power of Ant with easiness of maven. Gradle provides build files as well as tasks, which can be useful while building a project. Gradle uses a scripting language which proves to be much more powerful than XML files.
Another powerful build tool is SBT - Simple Build Tool. Though it can be used with JVM based languages, mainly it is used with in conjunction of Scala. This is the reason why it is also called Scala Build Tool sometimes. It uses Scala for DSL. Ivy is used as a dependency manager. SBT is a highly advanced tool similar to Gradle.
SDE-3 at JPMorgan Chase & Co. | Oracle | TCS | M.tech in Data Analytics from BITS-Pilani [WILP]
7 年Good work, Deepak ??