@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
1
Project discovery
Nx reads your
settings.gradle or settings.gradle.kts to find all included subprojects. Each subproject becomes an Nx project.2
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.3
Dependency graph
Nx reads the
dependencies block in each subproject’s build.gradle to build the project dependency graph, enabling nx affected to work correctly.