🍒 Cherry-Picked Nx v18.2 Updates
Tags: nx, monorepo, angular, gradle
Published: 2024-04-05 07:48:35

## **Release Note 18.2 (2024–03–28)**

https://github.com/nrwl/nx/releases/tag/18.2.0

## \[Angular\] Support Angular 17.3

As usual, Nx is up to date with the latest version of Angular!

{% embed https://blog.ninja-squad.com/2024/03/13/what-is-new-angular-17.3 %}

{% embed https://blog.angular.io/meet-angulars-new-output-api-253a41ffa13c %}

## \[Core\] Scope Nx Plugin Project Crystal 💛💛💛

{% embed https://github.com/nrwl/nx/pull/22379 %}

In my previous article, “[⛔ Target Exclusions in Nx Project Crystal](https://medium.com/javascript-in-plain-english/target-exclusions-in-nx-project-crystal-fbabce816b21),” I introduced alternatives for excluding certain projects from specific plugins.

For instance, you might not want a `test` target in an `e2e` project simply because there’s a `jest.config.ts` file present.

Now, **an official method is available** for excluding or including plugins for a specific project. Within your `nx.json` file, you can now specify the `exclude` or `include` options:

```json
{
  "plugins": [
    {
      "plugin": "@nx/jest/plugin",
      "options": {
        "targetName": "test",
        "exclude": ["my-lib-e2e/**/*"]
      }
    }
  ]
}
```

## \[Gradle\] New Gradle Integration

{% embed https://nx.dev/nx-api/gradle %}

You can now leverage the new Gradle integration with the [`@nx/gradle:init`](https://nx.dev/nx-api/gradle/generators/init) generator. To initialize, simply run:

```bash
nx g @nx/gradle:init
```

This initialization will also add the `@nx/gradle/plugin` to your `nx.json`:

```json
{
  "plugins": [
    {
      "plugin": "@nx/gradle/plugin",
      "options": {
        "testTargetName": "build",
        "classesTargetName": "test",
        "buildTargetName": "classes"
      }
    }
  ]
}
```

This plugin will:

* Integrate your Gradle projects into the Nx Dependency Tree by scanning all Gradle configurations.
    
* Discover your projects by scanning the Gradle configuration matching the pattern `**/build.{gradle.kts,gradle}`, and then assign the targets `build`, `test`, and `classes`.
    

## \[Cypress\] New target `open-cypress` is added by the @nx/cypress/plugin

{% embed https://github.com/nrwl/nx/pull/22556 %}

If you’re working with Nx Project Crystal and have a Cypress project that includes a `cypress.config.*` file, the `@nx/cypress/plugin` [will automatically add related targets to your project](https://nx.dev/nx-api/cypress/documents/overview#how-nxcypress-infers-tasks).

A new target, `open-cypress`, will now be added to your project configuration:

```json
"open-cypress": {
  "command": "cypress open",
  "options": {
    "cwd": ".",
  },
```

You have the flexibility to use a different name by specifying the new plugin option `openTargetName`:

```json
{
  "plugins": [
    {
      "plugin": "@nx/cypress/plugin",
      "options": {
        "targetName": "e2e",
        "ciTargetName": "e2e-ci",
        "componentTestingTargetName": "component-test",
        "openTargetName": "open-cypress" // <-- NEW
      }
    }
  ]
}
```

---

> **Looking for some help?** 🤝
> **Connect with me on [***Twitter***](https://twitter.com/jonathan_gelin) • [***LinkedIn***](https://www.linkedin.com/in/jonathan-gelin/) • [***Github***](https://github.com/jogelin)