packages/gradle/project-graph/README.md
This gradle plugin contains
Kotlin build.gradle.kts
plugins {
id("dev.nx.gradle.project-graph") version("+")
}
Groovy build.gradle
plugins {
id "dev.nx.gradle.project-graph" version "+"
}
./gradlew nxProjectGraph
In terminal, it should output something like:
> Task :nxProjectGraph
< your workspace >/build/nx/add-nx-to-gradle.json
To pass in a hash parameter:
./gradlew nxProjectGraph -Phash=12345
To control whether Nx generates individual targets for each Gradle task (atomized targets) or a single target for the entire Gradle project, set the atomized boolean in your build.gradle or build.gradle.kts file.
To disable atomized targets:
nxProjectReport {
atomized = false
}
It generates a json file to be consumed by nx:
{
"nodes": {
"app": {
"targets": {}
}
},
"dependencies": [],
"externalNodes": {}
}
The plugin provides a type-safe nx {} DSL for configuring Nx-specific metadata on your Gradle projects and tasks.
Configure project metadata such as name, tags, and custom properties:
Kotlin (build.gradle.kts):
import dev.nx.gradle.nx
nx {
set("name", "my-custom-name")
array("tags", "api", "backend")
}
Groovy (build.gradle):
import static dev.nx.gradle.Groovy.nx
nx(project) {
it.set 'name', 'my-custom-name'
it.array 'tags', 'api', 'backend'
}
Configure Nx target-specific behavior on individual tasks:
Kotlin (build.gradle.kts):
import dev.nx.gradle.nx
tasks.named("integrationTest") {
nx {
set("cache", true)
}
}
Groovy (build.gradle):
import static dev.nx.gradle.Groovy.nx
tasks.named('integrationTest') {
nx(it) {
it.set 'cache', true
}
}
For complete documentation on the Gradle DSL including all available options and examples, see the Gradle plugin configuration guide.