knowledge-kitchen

System Build Tools - Make, Maven, Gradle, NPM, Pip, Grunt, Gulp, etc.

System building in preparation for execution.

  1. Overview
  2. Common Features of Build Tools
  3. Stages
  4. Continuous Integration
  5. Make: The Original Build Tool
  6. Java Build Tools
  7. Intermission
  8. JavaScript Build Tools
  9. Python Build Tools
  10. Conclusions

Overview

Concept

System building is the process of creating complete, executable system by compiling and linking the system components, external libraries, configuration files, and other information.

Challenge

System building must take into account many complex environmental and programmatic factors, and steps must often be performed in a particular sequence in order for the build to succeed.

Solution

Automated build tools are generally necessary to handle the complexity.

Common Features of Build Tools

Build Script Generation

The build system should analyze the program that is being built, identify dependent components, and automatically generate a build script (configuration file).

The system should also support the manual creation and editing of these build scripts.

Version Control Integration

The build system should be able to check out the required versions of components from a version control system.

Minimal Recompilation

The build system should work out what source code needs to be recompiled and set up compilations as necessary.

Executable System Creation

The build system should link the compiled object code files with each other and with other required files, such as libraries and configuration files, to create an executable system

Test Automation

Build systems should be able to integrate with test automation tools such as xUnit other similar unit testing tools which check that the build has not been “broken” by the changes.

Reporting

The build system should provide reports about the success or failure of the build and the tests that have been run.

Documentation

The build system configuration script serves as a form of documentation

Stages

Developer’s Machine

Developers may wish to test and build locally before performing the ‘official’ build.

They will typically check out the latest version from the version control system and try to build it locally.

The developer’s machine often differs significantly from the target machine that code will be deployed to.

Build Server

Used to build the definitive version of the system.

Should integrate with the version control system to build the latest.

Target Machine

The platform on which the system is ultimately intended to execute. This may be significantly different from the development machines and build servers.

Keeping the developer’s machines and the build server environment in close emulation of the Target Environment is a whole ‘nother area of automation.

In cases where the target machines differ significantly from the others, testing cannot be complete until done on a target machine.

Continuous Integration

Automated Build and Test

Agile methodology promotes the practice of very frequent automated builds and automated testing once the build is done.

The Original Build Tool

Make

Make, included in UNIX starting in 1976, and the many automation tools derived from the original make, is considered a classic build automation tool.

Stuart Feldman

Make (continued)

Key features:

Make (continued again)

See…

Make (continued once more)

“If you move stuff around and do more than just invoking the compiler (and even then), the platform-specific stuff gets very awkward to handle in make. And having a makefile which only works on one system isn’t very nice for a cross-platform language”

-Joey, from Stack Overflow

Make has a few limitations that have led to the development of later build systems:

Java Build Tools

Ant

Apache Ant, begun in 2000, is a popular automated build tool that was designed explicitly to address some of the shortcomings of Make for Java builds.

Ant (continued)

Key features:

Ant (continued again)

See an example of an Ant build.xml file.

Ant (again once more)

Ant has suffered criticism on a few fronts:

Maven

Apache Maven is a successor to Apache Ant, initially released in 2004, that aims to address some of Ant’s shortcomings, plus adding some additional features.

Maven (continued)

Key features:

Maven (continued again)

See an example of a Maven pom.xml build file.

Maven (continued again once more)

Like build systems before it, Maven has its critics.

Gradle

Gradle is [yet another] open source build automation tool primarily focused on Java projects.

Gradle

Key features:

Gradle (continued again)

See an example of a Gradle build.gradle file.

Intermission

Package managers

A “package” is software that has been designed to be easily distributed via a “package manager” (sometimes called a dependency manager) so that others can easily download, install, configure, and use the package in their own applications.

Package managers thus maintain repositories of packages and provide the tools to install and configure those packages.

Now on with the show

As we’ll see, the Javascript and Python build tools ecosystems center heavily on package managers.

JavaScript Build Tools

Overview

JavaScript has one of the most sophisticated and rapidly evolving tooling environment of any language. Some popular build-related tools include:

Package managers

npm and yarn are package managers for Javascript that have build-related capabilities.

Webpack and parcel

webpack and parcel are bundlers for Javascript.

Python Build Tools

Overview

The Python build tool ecosystem has historically been less developed, but has recently taken inspiration from Java and JavaScript. Some popular tools:

Package managers and virtual environments

pip is the default package managers for Python. pip is used to document, install, and manage dependencies in most Python projects

conda is a competitor package manager like pip that also manages virtual environments like venv and pipenv. It is part of the popular Anaconda data science toolkit.

Distutils and setuptools

When it comes to creating packages so that software is easily distributed from the PyPI via pip or conda, Python has two main tools:

In practice, one need only use build directly, as this provides a high-level interface to the functionality of setuptools and distools - see discussion on this point.

twine is a tool for publishing packages to the PyPI repository so others can access, install, and use them.

Python’s build ecosystem (continued)

Python builds result in packages consisting of two artifacts:

Conclusions

You have seen some of the most significant software build tools and how they have evolutionarily progressed throughout build system history.