Skip to content

Java parser should auto-detect package prefix instead of relying on project name #98

@mircealungu

Description

@mircealungu

Problem

The Java parser regex matches imports using the name field from archlens.json:

import\s+(static\s+)?{{ProjectName}}\.(.+);

For a project like Apache Wayang, the Java imports are import org.apache.wayang.xxx, but a user would naturally set "name": "wayang". The parser finds zero dependencies because it looks for import wayang.xxx.

The workaround is to set "name": "org.apache.wayang" but this is unintuitive — the name field is supposed to be the project name, not the Java package prefix.

Suggestion

The parser could:

  1. Auto-detect the common package prefix by scanning the package declarations in the Java source files
  2. Add a separate config field like "packagePrefix" for Java/Kotlin projects
  3. Or simply match all import statements and filter to internal dependencies based on which packages are found in the source tree

The same issue likely applies to the Kotlin parser which uses a similar approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions