Skip to content

[Bug] External dependency im4java incorrectly classified as internal due to targetLabel collision with local 3rdparty/java #48

@runchen0919

Description

@runchen0919

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

  1. Add im4java as an external dependency in a Bazel-based project.
  2. Ensure the local project contains a directory at <repoRoot>/3rdparty/java.
  3. Run the project synchronization/loading process.
  4. Observe that im4java is 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-out and contains the external directory segment, it must be classified as an external dependency, regardless of whether its targetLabel matches 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions