Dependency Scanner Fails in Multi-Module Gradle Projects Due to Incorrect Root Path Assumption
Problem
A customer on an Ultimate trial is experiencing an issue with the dependency scanner in a multi-module Gradle project where some subprojects depend on other subprojects within the same repository. Despite successfully generating dependency reports and indicating BUILD SUCCESSFUL, the process fails with an error: "failed to normalize." This issue occurs specifically when there are interdependent, multi-module projects situated at the same level in the directory hierarchy.
Proposed Solution
To resolve this issue, we need to correct the path normalization logic by accurately computing the root paths for each subproject. This involves identifying the directory segment immediately preceding build/reports in the report paths and using this information to correctly relocate the dependency report files.
Implementation Plan
-
Simplify Root Path Computation:
- Update the
deriveRootPathfunction to compute the root path by splitting the report path at "build/reports" and identifying the preceding directory.
- Update the
-
Normalize Paths:
- Refactor the
normalizePathsfunction to iterate over the report paths, use the updatedderiveRootPathfunction to compute the new root paths, and relocate thehtmlDependencyReportartifacts adjacent to their respectivebuild.gradlefiles.
- Refactor the
-
Update Tests and Documentation:
- Modify the relevant tests to ensure they cover the new path normalization logic.
- Document the changes in the changelog and provide examples in the function comments for clarity.