Skip to content

[gradle/plugin-v1] createDependencies silently produces no edges for composite builds — single-quoted project names cause lookup failure #36858

Description

@romain-petit-whoz

Current Behavior

When using @nx/gradle/plugin-v1 with Gradle composite builds (includeBuild), createDependencies always returns an empty array. No inter-project dependencies appear in graph.dependencies for Gradle projects — every project only has its implicit conf dependency.

As a result, filterAffected cannot propagate changes through the Gradle dependency graph. Modifying a file in a leaf project never marks dependent projects as affected.

Root cause: processGradleDependencies parses the Gradle dependency report and stores project names with surrounding single quotes.

For example, the line:

+--- io.biznet.profile:hemera-api -> project ':hemera-api'

is parsed and stored as "':hemera-api'" (with quotes) in gradleProjectToDepsMap.

However, gradleProjectNameToProjectRootMap is keyed without quotes: ":hemera-api".

In createDependencies (dependencies.js), the lookup:

const targetProjectRoot = gradleProjectNameToProjectRootMap.get(dependedProject)

always returns undefined because dependedProject is "':hemera-api'" while the map key is ":hemera-api". The dependency is silently dropped.

Expected Behavior

Inter-project Gradle dependencies from composite builds appear as static edges in graph.dependencies, allowing filterAffected to correctly propagate changes through the Gradle dependency graph.

Reproduction context:

Gradle composite builds (includeBuild in settings.gradle)
Dependencies declared as implementation project(':some-subproject') across builds
The generated dependencies.txt report contains lines matching -> project ':xxx'

Minimal fix:

In createDependencies (src/plugin-v1/dependencies.js), strip the surrounding single quotes before the lookup:

// before

const targetProjectRoot = gradleProjectNameToProjectRootMap.get(dependedProject)

// after

const cleanDep = dependedProject.replace(/^'|'$/g, '')
const targetProjectRoot = gradleProjectNameToProjectRootMap.get(cleanDep)

Alternatively, fix at the source in processGradleDependencies to not store the quotes in the first place.

GitHub Repo

No response

Steps to Reproduce

  1. Set up an Nx workspace with @nx/gradle/plugin-v1 configured in nx.json
  2. Create at least two Gradle projects using composite builds (includeBuild in settings.gradle), where project B declares implementation project(':project-a') in its build.gradle
  3. Run nx reset to clear all caches
  4. Run any Nx command that builds the project graph (e.g. nx show projects)
  5. Inspect graph.dependencies for project B:
node -e "
const {createProjectGraphAsync} = require('@nx/devkit');
createProjectGraphAsync({exitOnError: true}).then(g => {
  console.log(JSON.stringify(g.dependencies['project-b'], null, 2));
});
"

Observed:

only { source: 'project-b', target: 'conf', type: 'implicit' } — no static dependency on project-a

Expected:

a { source: 'project-b', target: 'project-a', type: 'static' } edge

Nx Report

Node           : 22.22.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 10.28.1
daemon         : Disabled

nx                     : 22.7.5
@nx/js                 : 22.7.5
@nx/eslint             : 22.7.5
@nx/workspace          : 22.7.5
@nx/angular            : 22.7.5
@nx/jest               : 22.7.5
@nx/cypress            : 22.7.5
@nx/devkit             : 22.7.5
@nx/eslint-plugin      : 22.7.5
@nx/gradle             : 22.7.5
@nx/module-federation  : 22.7.5
@nx/node               : 22.7.5
@nx/playwright         : 22.7.5
@nx/plugin             : 22.7.5
@nx/rspack             : 22.7.5
@nx/storybook          : 22.7.5
@nx/web                : 22.7.5
@nx/webpack            : 22.7.5
@nx/docker             : 22.7.5
nx-cloud               : 19.1.0
@nrwl/nx-cloud         : 19.1.0
typescript             : 5.9.3
---------------------------------------
Registered Plugins:
./tools/gradle-plugin/src/index.ts
./tools/docker-plugin/src/index.ts
./tools/gcs-plugin/src/index.ts
./tools/quality-plugin/src/index.ts
@whoz/security-and-compliance-plugin
---------------------------------------
Community plugins:
@compodoc/compodoc    : 1.2.1
@ngrx/component-store : 21.0.1
@ngrx/effects         : 21.0.1
@ngrx/operators       : 21.0.1
@ngrx/schematics      : 21.0.1
@ngrx/signals         : 21.0.1
@ngrx/store           : 21.0.1
@ngrx/store-devtools  : 21.0.1
@storybook/angular    : 10.2.10
angular-eslint        : 21.0.1
ngxtension            : 4.3.2
---------------------------------------
Local workspace plugins:
@whoz/security-and-compliance-plugin
@whoz/tools-workspace-plugin
@whoz/tools-docker-plugin
@whoz/tools-gcs-plugin
@whoz/tools-pso-utils
@whoz/tools-validate
@whoz/tools-release
@whoz/tools-shared
@whoz/tools-build
@whoz/tools-e2e
---------------------------------------
Cache Usage: 0.00 B / 46.04 GB
---------------------------------------
⚠️ Multiple Nx versions detected

Your workspace uses nx@22.7.5, but other packages depend on a different version:
  - aphrodite-feature-qualification-detail → ngxtension → nx@20.8.4
  - @nx/eslint-plugin → @nx/devkit → nx@23.1.0

These packages should not have nx as a dependency. Please report this issue to the package maintainers.
Run `pnpm why nx@20.8.4` for more details.
Run `pnpm why nx@23.1.0` for more details.

Failure Logs

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Metadata

Metadata

Assignees

Labels

priority: mediumMedium Priority (not high, not low priority)scope: javaIssues related to Java and Gradletype: bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions