Skip to content

Fixed list of top-level package name is flawed for uncommon TLD's #280

Closed
@nickbreen

Description

@nickbreen

https://github.com/bazel-contrib/rules_jvm/blob/0bef82e8d7038a6628faad06b9a57d10e536c2c5/java/private/package.bzl#L2C1-L2C72

The implementation is fundamentally flawed.

For example, I've just spent a few hours trying to figure out why my test classes were not being properly named for their package (TLD of kiwi), in my specific case, tests in src/test/java/kiwi/**/*. All country-code TLD based packages would fail too.

Bazel itself appears to use a heuristic based on the maven-style layout of a prefix of src/test/java/ which is even noted in a comment!

The simplest mitigation is probably to allow the prefix to be specified in the rule. E.g.

java_test_suite(
    name = "test",
    size = "small",
    srcs = glob(["src/test/java/**/*"]),

    src_prefix = "src/test/java",

    resources = glob(["src/test/resources/**/*"]),
    runner = "junit5",
    runtime_deps = JUNIT5_DEPS,
    deps = [
        ":lib",
        artifact("org.junit.jupiter:junit-jupiter-api"),
    ],
)

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