Java Build Tools + Dependency Management for Test Automation
Build Tools - History:
- Save developers some time typing commands that would have many source code modules compiled and linked in a particular order.
- First build tool was Make a scripting language that allowed a build script to be written as a series of compile-and-link steps
- GNU version of Make offered additional features, such as dependency management and incremental building
Java now has Maven, Gradle, Ant and some others (like Scala’s Simple Build Tool–SBT)
Ant was the first of the so-called “modern build tools”, and is used for automating build process. In theory, it is kind of like Make, without Make’s wrinkles. It is implemented in Java and used mostly for Java projects. The first public release of Ant was in 2000, and it quickly became most popular build tool for Java projects thanks to being platform independent (like Java), having low barriers for getting set up, and providing repeatable builds. Later, it also gained the ability to accept plugins.
However, Ant was criticized for having some drawbacks. Build scripts are written in XML, which is hierarchical by nature and not suitable for procedural programming, something often needed in build scripts. Ant is often claimed to be overly verbose, which means it can eventually make build scripts for large projects unmanageably big.
Maven was first released in 2004 and designed to improve upon some of the issues developers had with Ant and other build tools at the time. Maven’s biggest achievements are considered to be the introduction of project structure conventions, dependency management and a central artifact repository, Maven Central.
Maven still uses XML for writing a build file (pom.xml), but the structure is very different because it became declarative. Now developers don’t have to write down all the commands that lead to some goals, but instead he describes the structure of the project (if it differentiates from the conventions) and Maven itself provides the available targets that a programmer can invoke. Plus, Maven is capable of downloading dependencies through a network.
Gradle is the youngest build tool of the three and its developers tried to combine Ant’s power and flexibility with Maven’s dependency management and conventions to create nice and shiny build tool. After several years of developers, Gradle v1.0 was released in 2012, and has quickly started to gain popularity. It’s developing really fast and already adopted by some big enterprises–Gradle, for example, was selected to be the build tool for Google’s Android OS.
One interesting point is that with Gradle, XML is not used anymore–instead, developers have a Domain Specific Language (DSL) based on the JVM language Groovy, which was invented so that developers could ditch the verbosity of XML and write more simple and clear statements. This has sparked a debate among users as to whether the standard, easily-understandable (but long-winded) style of XML is better or worse than DSL.
Here is a good insights into the Java build tools: