A general introduction to build tools
By Harshit Kandhway and Preeti Theraja
All of us will agree that software development is a complex process. Before we can see our application in the hands of the user it needs to be packaged into a binary executable. To package an application, we first need to ensure all dependencies are available, then we need to compile the source files(assuming we are using a statically typed programming language like Java) against the dependencies, then run our test cases, and finally we can package our application. Most of the time we are not done at the packaging step we also need to copy the binary package to a location like Amazon S3 or Nexus or Artifactory. In a real-world enterprise application, there will be many more tasks in addition to what we just discussed.
You will agree with us that these tasks should not be done manually. It is not efficient if all of the developers have to do this drudge work each time they need to build a binary. Developer productivity will go down the floor.
This is the opportunity for automation. Intelligent developers before us realized this pain and created tools to automate this process. This automation process is called build automation. As per wikipedia,
Build automation is the process of automating the creation of a software build and the associated processes including: compiling computer source code into binary code, packaging binary code, and running automated tests.
Build automation makes the process repeatable.
Build tools to the rescue
Build tool is a program that automates the process of compiling, testing ,packaging and deploying of source code in the most efficient manner. It requires very little human interaction helping developers improve their productivity. The developers can focus the saved time on actual software development activities like coding instead of doing the drudge work.
Some of the open source build tools are Make, Maven,Gradle, MSBuild, etc.
History of build tools
The first software build tool Make was created by Stuart Feldman in 1976. Feldman created Make to automate the process of building programs through the use of Make config files and automation. Make was the beginning of Build Automation. We have moved a long way since then.
Build tools have evolved over the years. They have become more powerful and feature rich.
Below is a visual timeline of build tools from a Java developer perspective:
1976 — MAKE, the first ever build tool
2000 — Apache Ant is born
2002 — Apache Maven 1.0 is launched
2004 — Ivy is introduced
2012 — Gradle 1.0 launched
The three popular build tools in Java ecosystem shows how builds tools philosophy has evolved over time.
Ant is all about flexibility. It does not impose any coding conventions or project structure.
Maven relies on convention over configuration. If you follow the conventions Maven will automatically understand what needs to be done.
Gradle combines flexibility of Ant with the conventions of Maven. It favors code-over-configuration philosophy that makes it easier to write concise and powerful build files.
Why build tools?
If you still need reasons why you should use a build tool we have compiled a list of the 5 reasons:
Reason 1: Automates the drudge work and makes developer productive
I don’t think we need to explain this more. Build tools automates the process of building an executable. This gives each developer the ability to build and run software on their machine.
Reason 2: Manage dependencies
A build tool can automate the process of downloading and managing dependencies for you. If you are a Java developer there is no need to keep JAR files in the lib folder and pushing it to the version control system. Build tool will ensure correct versions are used. This avoids integration headaches caused later in the project life.
Reason 3: Ensures correct execution order of commands
Knowing how to order the execution of commands based on dependencies is one of the most challenging tasks as most of the time output of one command is fed as input to the preceding. Hence it becomes impossible to manage the order manually for large project whereas build tools does this task automatically for us.
Reason 4: Saves time by parallelizing different tasks
When we run commands which are not dependent on each other then the build tool helps in running the commands parallely improving and boosting the execution time,unlike the sequential execution in case of manual build process. This saves developer time.
Reason 5: A precondition for continuous integration
Continuous Integration is a development practice that requires developers to integrate code into a shared repository several times a day. Each time the code is checked-in, it is verified by an automated build, allowing teams to detect problems early. As it is clear from the definition of CI it needs an automated build. Without build tool, you can’t have CI.