Skip to content

CM-76621: Fix Gradle dependency restore on Gradle 9 and remapped subprojects - #589

Merged
omer-roth merged 3 commits into
mainfrom
CM-76621-gradle-9-restore
Nov 8, 2026
Merged

omer-roth merged 3 commits into
mainfrom
CM-76621-gradle-9-restore

Conversation

@omer-roth

Copy link
Copy Markdown
Collaborator

What changed

  • Default restore: gradle dependencies -b <manifest> → gradle -p <manifest dir> dependencies. Gradle 9 removed -b, so restore failed on Gradle 9. -p starts Gradle in the manifest directory. Gradle then finds the root settings file and selects the project whose projectDir is that directory, so remapped and nested projects work too.
  • --gradle-all-sub-projects: before, the project path was guessed as ':' + <dir name>. That missed projects with a remapped projectDir and nested projects, and skipped them with no message. Manifest directories are now mapped to project paths using the "Project locations" section of gradle projects (Gradle 9.1+). Paths in that section are relative to the build root, and the mapping works out the build root even when the scan root is a subproject directory.
  • Older Gradle (no locations section): keeps the directory-name fallback, which now also handles the root manifest (→ dependencies).
  • Skipped manifests are logged at debug level.

Why

CM-76621: a customer on Gradle 9.8.1 got no SCA results. The third part of that ticket, missing JFrog credentials on the runner, is server-side and not in this PR.

Verification

  • Unit tests added for: the -p default, remapped and nested projects, the root manifest, a manifest outside the build, relative paths, CRLF output, Windows separators (runs on win32 only), a subproject scan root, and the older-Gradle fallback. SCA suite: 368 passed, 1 skipped. Ruff check and format are clean.
  • Ran the real restore code against a sample multi-project build (remapped projectDir + nested project):
    • Gradle 9.2.0 / 9.5.1 / 9.8.1 × JDK 17 / 21 / 25: both modes OK on all manifests.
    • Gradle 8.9 × JDK 17 / 21: default mode OK. Sub-projects mode uses the fallback, so remapped and nested projects are still skipped there, as before.
    • Gradle 8.x × JDK 25: Gradle itself can't run on JDK 25, unrelated to this change.

Reviewer notes

  • Gradle 9.0.x and 8.14 were not tested locally because the download failed. If "Project locations" is missing in some version, the code falls back to the old behavior.
  • The sample build has no real dependencies, so these runs check project selection only, not dependency resolution.

🤖 Generated with Claude Code

…rojects

Gradle 9 removed the -b (--build-file) option, so the default restore
failed. Run `gradle -p <manifest dir> dependencies` instead: Gradle finds
the root settings file and selects the project whose projectDir matches.

With --gradle-all-sub-projects, the project path was guessed from the
directory name, which missed remapped projectDirs and nested projects and
skipped them silently. Map manifest directories to project paths using
the "Project locations" section of `gradle projects` (Gradle 9.1+),
anchored to the build root even when the scan root is a subproject.
Older Gradle versions keep the directory-name fallback, which now also
handles the root manifest. Skipped manifests are logged at debug level.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
omer-roth and others added 2 commits November 8, 2026 12:19
CM-76621 remove narration commetn
Drop comments that narrate Gradle version history and extract the
build-root lookup into _find_build_root so the code reads on its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omer-roth
omer-roth enabled auto-merge (squash) November 8, 2026 14:11
@omer-roth
omer-roth merged commit 72bd06f into main Nov 8, 2026
54 of 86 checks passed
@omer-roth
omer-roth deleted the CM-76621-gradle-9-restore branch November 8, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants