-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Issue Title:
[Bug] External dependency im4java incorrectly classified as internal due to targetLabel collision with local 3rdparty/java
Description
When the project depends on im4java, the targetLabel extracted from the JAR's MANIFEST.MF is 3rdparty/java. This causes a naming collision with the local project directory <repoRoot>/3rdparty/java.
The root cause is that the current classification logic fails to distinguish between an external artifact's metadata and the local repository structure. Because the strings match, the system incorrectly treats this external 3rd-party dependency as a local project module, leading to classpath conflicts or project loading failures.
Steps to Reproduce
- Add
im4javaas an external dependency in a Bazel-based project. - Ensure the local project contains a directory at
<repoRoot>/3rdparty/java. - Run the project synchronization/loading process.
- Observe that
im4javais erroneously mapped to the local directory instead of the external repository.
Expected Behavior
The system should correctly identify that a dependency is external by inspecting its source path, even if its targetLabel matches a local directory name.
Actual Behavior
The system identifies the targetLabel as 3rdparty/java and incorrectly prioritizes the local file system path, causing the project to fail during loading.
Suggested Fix
Refine the dependency classification logic by validating the source path of the target. A target should be strictly identified as an external dependency if its path resides within the Bazel output directory for external repositories.
Proposed Logic:
- Check if the target's path follows the Bazel output pattern:
bazel-out/<config>/bin/external/<repo_name>/.... - Validation Rule: If the path starts with
bazel-outand contains theexternaldirectory segment, it must be classified as an external dependency, regardless of whether itstargetLabelmatches a local directory.
Pseudo-code logic:
if (path.startsWith("bazel-out/") && path.contains("/external/")) {
isExternal = true;
// Do not map to local <repoRoot>
} else {
// Fallback to existing classification logic
}
Environment Context
- Affected Dependency:
im4java - Collision Path:
3rdparty/java - Build System: Bazel
- Impact: Project initialization failure due to misclassified dependencies.