Skip to content

Conversation

@shs96c
Copy link
Collaborator

@shs96c shs96c commented Sep 22, 2025

This means that if we see a directory structure like:

src/foo/java
src/foo/resources

We'll now generate a target in the resources directory which will be included in the target generated in the java directory. This models the behaviour of both maven and gradle which will put those resources into the single jar that they build.

Copy link
Collaborator

@stevebarrau stevebarrau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for having a look.

Maybe remove some of the AI handholding intra-function comments.

I was thinking about the case where the resources are used by compiler plugins and should thus be deps instead of runtimeDeps, but we can have a keep directive for this (I have no example of this but I am pretty sure some plugin in the wild does this).

@shs96c shs96c force-pushed the sourcesets branch 2 times, most recently from b697033 to 771d04a Compare October 6, 2025 11:57
shs96c added 2 commits October 6, 2025 13:05
This means that if we see a directory structure like:

  src/foo/java
  src/foo/resources

We'll now generate a target in the `resources` directory
which will be included in the target generated in the
`java` directory. This models the behaviour of both maven
and gradle which will put those resources into the single
jar that they build.
@shs96c shs96c merged commit 667689c into bazel-contrib:main Oct 6, 2025
7 checks passed
@shs96c shs96c deleted the sourcesets branch October 6, 2025 14:41
@H5-O5
Copy link

H5-O5 commented Nov 4, 2025

@shs96c This doesn't work for me. Could you explain why it works?

https://github.com/shs96c/rules_jvm/blob/2850f1a8019cb8bd59100c699114de7e3624da1d/java/gazelle/testdata/resources_custom_sourceset/src/sample/resources/BUILD.out

pkg_files(
    name = "resources",
    srcs = [
        "com/example/app.properties",
        "config.xml",
    ],
    strip_prefix = "src/sample/resources",
)

Basically if I just bazel build //path/to/dir:resources I got Error in fail: Could not strip prefix 'src/sample/resources'

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

Successfully merging this pull request may close these issues.

3 participants