Course contentsShow
← Software Engineering
Lesson 662 of 1,93321. Build Automation and Dependency ManagementFree lesson

Build Tasks and Targets

Defining build tasks: compile, test, package, deploy, and creating custom tasks for project needs.

Build Tasks and Targets

You'll learn: How build automation organizes work into named tasks (like compile, test, package) and how to define custom tasks tailored to your project's needs.

What Are Build Tasks?

A build task (or target) is a named, executable unit of work in your build process. Think of tasks as recipes: each recipe has a name and a list of steps. When you run a task, the build tool executes those steps in order.

Most projects use standard tasks that correspond to common build phases:

  • compile – Transforms source code into executable form (bytecode, binaries, transpiled JavaScript)
  • test – Runs automated tests to verify correctness
  • package – Bundles compiled code and resources into a distributable format (JAR, ZIP, Docker image)
  • deploy – Publishes or installs the package to a server, repository, or device
  • clean – Removes build artifacts to start fresh

These tasks often depend on each other. Running test typically requires compile to run first. Build tools handle these task dependencies automatically.

Creating Custom Tasks

Beyond the standard tasks, every project has unique needs. You might create custom tasks like:

  • generateDocs – Generate API documentation
  • lintCode – Run code quality checks
  • runMigrations – Apply database schema changes
  • buildDocker – Create container images

Custom tasks let you automate repetitive project-specific work and integrate it into your CI pipeline.

The Analogy

Think of your build configuration as a control panel with labeled buttons. Each button (compile, test, deploy) triggers a specific sequence of actions. You press one button, and the build tool orchestrates everything needed to complete that task—including pressing other buttons first if necessary.

Key Takeaway:
Build tasks organize your build process into named, reusable units of work. Standard tasks handle common phases (compile, test, package, deploy), while custom tasks address project-specific automation needs.