Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nickbreen opened this issue Jun 15, 2024 · 3 comments
Closed

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

nickbreen opened this issue Jun 15, 2024 · 3 comments

Comments

@nickbreen
Copy link

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"),
    ],
)
@nickbreen
Copy link
Author

nickbreen commented Jun 15, 2024

Just found #104 and #121

@nickbreen
Copy link
Author

nickbreen commented Jun 15, 2024

So, the work-around is to specify package_prefixes:

package_prefixes = [".nz.", ".kiwi.", ".xyz."],

This is just missing from the documentation.

@nickbreen
Copy link
Author

Closing as it's just a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant