Skip to Content
Learning & KnowledgeBooks & SummariesGradle in Action Book Summary – Build Automation & Build Tools

Gradle in Action

Key Lessons

Build tool creates a DAG of the tasks and its dependencies.

Gradle

  • DSL in Groovy
  • JVM native
  • Each element in a Gradle script has a one-to-one representation with a Java class

Useful Commands

  • gradle tasks --all
  • gradle properties

Gradle Daemon

Fork of the Gradle process in the background to reuse the previous process

Plugins

  • java—for finding the Java classes and configuring smart defaults
  • application—tasks for simplifying running the app and bundling

Gradle Wrapper

Works to have the same versions of Gradle on the machine.

Main Things in Gradle

  • Projects
  • Tasks
  • Properties

Gradle Lifecycle Phases

  • Initialization—creating a project instance for the project
  • Configuration—constructing a model representation of the tasks that will take part in the build
    • All tasks are checked
    • Task inputs and outputs are evaluated to wire up the task dependencies
  • Execution—tasks are executed in the correct order (determined by the dependencies)

Gradle Hooks

  • Before and after different phases (configuration, execution, etc.)

Additional Commands

  • gradle dependencyInsight

Settings File

  • Declares configuration required for instantiating project hierarchy

Project Configuration

  • allprojects—common behavior for all (including root)
  • subprojects—only subprojects
Last updated on