Marian Klühspies
Marian Klühspies

Reputation: 17687

How to make Nx ignore yarn.lock / package-lock.json to not affect a specific project?

I've combined multiple technologies in a single monorepo, specifically Node and Gradle.

With the current setup, a version change of Node dependencies will trigger Gradle build and deploys, as Nx is using changes from yarn.lock to affect all packages.

To come around that, I've tried to define custom namedInputs

    "gradle": [
      "default",
      "!{workspaceRoot}/package.json",
      "!{workspaceRoot}/yarn.lock",
      "!{workspaceRoot}/package-lock.json",
      "{workspaceRoot}/build.gradle.kts",
      "{workspaceRoot}/settings.gradle.kts",
      "{workspaceRoot}/gradle/*.toml",
      "{workspaceRoot}/infrastructure/",
      {

where I explicitly exclude yarn.lock

and use that in my Gradle project's project.json

{
  "name": "@my-workspace/my-gradle-project",
  "$schema": "../../../node_modules/nx/schemas/project-schema.json",
  "projectType": "application",
  "tags": ["staging"],
  "targets": {
    "build": {
      "inputs": [
        "gradle"
      ]
    }
  }
}

However, running

nx show projects --with-target=build --affected --uncommitted

with uncommitted changes manually made in yarn.lock shows that project getting affected along with all others still.

What do I need to do to prevent Nx from affecting my Gradle project when yarn.lock changes are made?

Upvotes: 0

Views: 48

Answers (0)

Related Questions