TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nrwl/nx/llms.txt
Use this file to discover all available pages before exploring further.
@nx/gradle plugin brings Nx’s monorepo capabilities to Java and Kotlin projects managed by Gradle. It infers tasks directly from your Gradle project structure, maps Gradle tasks to Nx targets, and enables affected builds, task caching, and the Nx project graph for multi-project Gradle workspaces.
Installation
@nx/gradle requires Gradle to be installed and available on the PATH, or a gradlew wrapper script present in your workspace root.What the plugin provides
Inferred tasks
Automatically discovers all Gradle subprojects and maps every Gradle task to an Nx target — no manual configuration needed.
Executors
The
gradle executor runs any Gradle task through the Gradle Tooling API or gradlew, with Nx caching support.CI workflow
The
ci-workflow generator scaffolds a CI pipeline configured to run Nx in a Gradle monorepo.Generators
ci-workflow
Scaffold a CI workflow configuration that runs Nx commands for a Gradle-based workspace.Executors
gradle
Run any Gradle task via the Gradle Tooling API or by invokinggradlew. Supports batch execution for running multiple tasks efficiently.
In practice, you rarely need to write this configuration manually. The
@nx/gradle plugin infers these targets directly from your build.gradle or build.gradle.kts files.Inferred tasks
This is the primary feature of@nx/gradle. Register the plugin in nx.json and Nx will automatically discover every Gradle subproject and every task it exposes.
How task inference works
Project discovery
Nx reads your
settings.gradle or settings.gradle.kts to find all included subprojects. Each subproject becomes an Nx project.Task mapping
For each subproject, Nx queries Gradle for available tasks and maps them to Nx targets. Standard tasks like
build, test, check, and clean are mapped by default.Configuration examples
Multi-project Gradle workspace
A typical multi-project Gradle workspace structure:settings.gradle.kts
api/build.gradle.kts
nx.json with caching configuration
Working with affected commands
Nx tracks which Gradle subprojects are affected by source changes, allowing you to skip tasks for unchanged projects:Nx and Gradle side by side
You can run tasks using either the Nx CLI or Gradle directly. They are equivalent:| Nx command | Gradle equivalent |
|---|---|
nx build mylib | ./gradlew :mylib:build |
nx test mylib | ./gradlew :mylib:test |
nx run mylib:check | ./gradlew :mylib:check |
nx affected -t test | (no Gradle equivalent) |
