diff --git a/docs/generated/manifests/menus.json b/docs/generated/manifests/menus.json index 3ae590666e..c32b30ba05 100644 --- a/docs/generated/manifests/menus.json +++ b/docs/generated/manifests/menus.json @@ -8001,6 +8001,23 @@ "path": "/nx-api/gradle", "name": "gradle", "children": [ + { + "id": "documents", + "path": "/nx-api/gradle/documents", + "name": "documents", + "children": [ + { + "name": "Overview", + "path": "/nx-api/gradle/documents/overview", + "id": "overview", + "isExternal": false, + "children": [], + "disableCollapsible": false + } + ], + "isExternal": false, + "disableCollapsible": false + }, { "id": "generators", "path": "/nx-api/gradle/generators", diff --git a/docs/generated/manifests/nx-api.json b/docs/generated/manifests/nx-api.json index a9059a6280..de8487215e 100644 --- a/docs/generated/manifests/nx-api.json +++ b/docs/generated/manifests/nx-api.json @@ -1012,7 +1012,19 @@ "name": "gradle", "packageName": "@nx/gradle", "description": "The Nx Plugin for Gradle allows Gradle tasks to be run through Nx", - "documents": {}, + "documents": { + "/nx-api/gradle/documents/overview": { + "id": "overview", + "name": "Overview", + "description": "The Nx Plugin for Gradle allows Gradle tasks to be run through Nx", + "file": "generated/packages/gradle/documents/overview", + "itemList": [], + "isExternal": false, + "path": "/nx-api/gradle/documents/overview", + "tags": [], + "originalFilePath": "shared/packages/gradle/gradle-plugin" + } + }, "root": "/packages/gradle", "source": "/packages/gradle/src", "executors": {}, diff --git a/docs/generated/packages-metadata.json b/docs/generated/packages-metadata.json index 8cf6153029..7f896eb08c 100644 --- a/docs/generated/packages-metadata.json +++ b/docs/generated/packages-metadata.json @@ -998,7 +998,19 @@ }, { "description": "The Nx Plugin for Gradle allows Gradle tasks to be run through Nx", - "documents": [], + "documents": [ + { + "id": "overview", + "name": "Overview", + "description": "The Nx Plugin for Gradle allows Gradle tasks to be run through Nx", + "file": "generated/packages/gradle/documents/overview", + "itemList": [], + "isExternal": false, + "path": "gradle/documents/overview", + "tags": [], + "originalFilePath": "shared/packages/gradle/gradle-plugin" + } + ], "executors": [], "generators": [ { diff --git a/docs/generated/packages/gradle/documents/overview.md b/docs/generated/packages/gradle/documents/overview.md new file mode 100644 index 0000000000..354916e893 --- /dev/null +++ b/docs/generated/packages/gradle/documents/overview.md @@ -0,0 +1,82 @@ +--- +title: Overview of the Nx Gradle Plugin +description: The Nx Plugin for Gradle allows Gradle tasks to be run through Nx. +--- + +[Gradle](https://gradle.org/) is a fast, dependable, and adaptable open-source build automation tool with an elegant and extensible declarative build language. Gradle supports Android, Java, Kotlin Multiplatform, Groovy, Scala, Javascript, and C/C++. + +The Nx Gradle plugin registers Gradle projects in your Nx workspace. It allows Gradle tasks to be run through Nx. Nx effortlessly makes your [CI faster](/ci/intro/ci-with-nx). + +Nx adds the following features to your workspace: + +- [Cache task results](/features/cache-task-results) +- [Distribute task execution](/ci/features/distribute-task-execution) +- [Run only tasks affected by a PR](/ci/features/affected) +- [Interactively explore your workspace](/features/explore-graph) + +## Add Nx to a Gradle Workspace + +In any Gradle workspace, run the following command to add Nx and select @nx/gradle: + +```shell {% skipRescope=true %} +npx nx@latest init +``` + +Then, you can run Gradle tasks using Nx. For example: + +{% tabs %} +{% tab label="Mac/Linux" %} + +```shell {% skipRescope=true %} +./nx build +``` + +{% /tab %} +{% tab label="Windows" %} + +```shell {% skipRescope=true %} +nx.bat build +``` + +{% /tab %} +{% /tabs %} + +## Setting Up @nx/gradle in a Nx Workspace + +In any Nx workspace, you can install `@nx/gradle` by running the following command: + +```shell {% skipRescope=true %} +nx add @nx/gradle +``` + +## How @nx/gradle Infers Tasks + +The `@nx/gradle` plugin will create an Nx project for each Gradle configuration file present. Any of the following files will be recognized as a Gradle configuration file: + +- `gradle.build` +- `gradle.build.kts` + +### @nx/gradle Configuration + +The `@nx/gradle` is configured in the `plugins` array in `nx.json`. + +```json {% fileName="nx.json" %} +{ + "plugins": [ + { + "plugin": "@nx/gradle", + "options": { + "testTargetName": "test", + "classesTargetName": "classes", + "buildTargetName": "build" + } + } + ] +} +``` + +Once a Gradle configuration file has been identified, the targets are created with the name you specify under `testTargetName`, `classesTargetName` or `buildTargetName` in the `nx.json` `plugins` array. The default names for the inferred targets are `test`, `classes` and `build`. + +## View Inferred Tasks + +To view inferred tasks for a project, open the [project details view](/features/explore-graph#explore-projects-in-your-workspace) in Nx Console or run `nx show project my-project --web` in the command line. diff --git a/docs/map.json b/docs/map.json index 26f279d48d..de38c987c6 100644 --- a/docs/map.json +++ b/docs/map.json @@ -2544,6 +2544,19 @@ "file": "shared/packages/expo/expo-plugin" } ] + }, + { + "name": "gradle", + "id": "gradle", + "description": "Gradle package.", + "itemList": [ + { + "id": "overview", + "name": "Overview", + "path": "/nx-api/gradle", + "file": "shared/packages/gradle/gradle-plugin" + } + ] } ] } diff --git a/docs/shared/packages/gradle/gradle-plugin.md b/docs/shared/packages/gradle/gradle-plugin.md new file mode 100644 index 0000000000..354916e893 --- /dev/null +++ b/docs/shared/packages/gradle/gradle-plugin.md @@ -0,0 +1,82 @@ +--- +title: Overview of the Nx Gradle Plugin +description: The Nx Plugin for Gradle allows Gradle tasks to be run through Nx. +--- + +[Gradle](https://gradle.org/) is a fast, dependable, and adaptable open-source build automation tool with an elegant and extensible declarative build language. Gradle supports Android, Java, Kotlin Multiplatform, Groovy, Scala, Javascript, and C/C++. + +The Nx Gradle plugin registers Gradle projects in your Nx workspace. It allows Gradle tasks to be run through Nx. Nx effortlessly makes your [CI faster](/ci/intro/ci-with-nx). + +Nx adds the following features to your workspace: + +- [Cache task results](/features/cache-task-results) +- [Distribute task execution](/ci/features/distribute-task-execution) +- [Run only tasks affected by a PR](/ci/features/affected) +- [Interactively explore your workspace](/features/explore-graph) + +## Add Nx to a Gradle Workspace + +In any Gradle workspace, run the following command to add Nx and select @nx/gradle: + +```shell {% skipRescope=true %} +npx nx@latest init +``` + +Then, you can run Gradle tasks using Nx. For example: + +{% tabs %} +{% tab label="Mac/Linux" %} + +```shell {% skipRescope=true %} +./nx build +``` + +{% /tab %} +{% tab label="Windows" %} + +```shell {% skipRescope=true %} +nx.bat build +``` + +{% /tab %} +{% /tabs %} + +## Setting Up @nx/gradle in a Nx Workspace + +In any Nx workspace, you can install `@nx/gradle` by running the following command: + +```shell {% skipRescope=true %} +nx add @nx/gradle +``` + +## How @nx/gradle Infers Tasks + +The `@nx/gradle` plugin will create an Nx project for each Gradle configuration file present. Any of the following files will be recognized as a Gradle configuration file: + +- `gradle.build` +- `gradle.build.kts` + +### @nx/gradle Configuration + +The `@nx/gradle` is configured in the `plugins` array in `nx.json`. + +```json {% fileName="nx.json" %} +{ + "plugins": [ + { + "plugin": "@nx/gradle", + "options": { + "testTargetName": "test", + "classesTargetName": "classes", + "buildTargetName": "build" + } + } + ] +} +``` + +Once a Gradle configuration file has been identified, the targets are created with the name you specify under `testTargetName`, `classesTargetName` or `buildTargetName` in the `nx.json` `plugins` array. The default names for the inferred targets are `test`, `classes` and `build`. + +## View Inferred Tasks + +To view inferred tasks for a project, open the [project details view](/features/explore-graph#explore-projects-in-your-workspace) in Nx Console or run `nx show project my-project --web` in the command line. diff --git a/docs/shared/reference/sitemap.md b/docs/shared/reference/sitemap.md index 91eed66813..8edea94c8c 100644 --- a/docs/shared/reference/sitemap.md +++ b/docs/shared/reference/sitemap.md @@ -450,6 +450,8 @@ - [init](/nx-api/express/generators/init) - [application](/nx-api/express/generators/application) - [gradle](/nx-api/gradle) + - [documents](/nx-api/gradle/documents) + - [Overview](/nx-api/gradle/documents/overview) - [generators](/nx-api/gradle/generators) - [init](/nx-api/gradle/generators/init) - [jest](/nx-api/jest)