Skip to content

fix: respect includes/excludes in maven resources#133

Merged
tgodzik merged 4 commits into
scalacenter:mainfrom
krrish175-byte:fix/issue-85-include-field-ignored
Jan 14, 2026
Merged

fix: respect includes/excludes in maven resources#133
tgodzik merged 4 commits into
scalacenter:mainfrom
krrish175-byte:fix/issue-85-include-field-ignored

Conversation

@krrish175-byte

@krrish175-byte krrish175-byte commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

Description:

This PR addresses issue #85 where the includes and excludes fields in the pom.xml
resources configuration were being ignored. This resulted in the entire resource directory being added to the classpath even when specific files were explicitly requested (e.g., LICENSE or NOTICE), causing shadowing issues.

Changes:

  • MojoImplementation.scala: Implemented DirectoryScanner to correctly process resource directories based on includes and excludes patterns. Refactored resource processing to handle List of paths correctly.

  • MavenConfigGenerationTest.scala: Added regression test issue85 to verify that includes are respected. Cleaned up unused imports.

Verification:

  • Run mvn test -Dtest=MavenConfigGenerationTest#issue85

  • Validated that all existing tests pass.

Fixing issue:

Fixes #85

@tgodzik @adpi2

if (Files.exists(dir)) {
if (a.getIncludes().isEmpty() && a.getExcludes().isEmpty()) {
Some(dir)
List(dir)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you add a test that verifies the fix?

@krrish175-byte

Copy link
Copy Markdown
Contributor Author

Hey @tgodzik, added a regression test defaultResources to MavenConfigGenerationTest.scala.

This new test ensures that when no <includes> are specified, we correctly fall back to adding the directory itself. The existing issue85 test case already covers the fix scenario where specific files are added when <includes> are present. Both tests are passing.

@tgodzik tgodzik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you are using AI, please verify that everything is properly tested. It really doesn't help us much if we have to review one PR many times and would be easier if we vibe code it ourselves.

I don't want to be too harsh here, but I do have limited time at my disposal.

@Test
def defaultResources() = {
check(
"basic_scala/pom.xml",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is an old test, which doesn't contain any includes.

@krrish175-byte

Copy link
Copy Markdown
Contributor Author

Hi @tgodzik, I understand your concern. Let me clarify why I used the basic_scala test:

I reused basic_scala/pom.xml for the defaultResources() test because it's a minimal Scala project that doesn't have any or configuration in its resources section. This makes it perfect for testing the default behavior when no includes/excludes are specified, the entire resource directory should be added to the bloop config, not individual files.

The issue_85 test specifically tests the opposite case: when ARE specified, individual files should be listed instead of the directory.

Regarding AI usage:

I did not use AI to write this code. I manually:

Read through the existing codebase to understand how resources are processed Identified the bug in MojoImplementation.scala where the includes field was being ignored, created the issue_85 test case based on the issue description, added the defaultResources() test to ensure my fix didn't break the default behavior.

I apologize if the code structure seemed suspicious. I'm happy to make any changes you'd like to see.

@tgodzik tgodzik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am sorry if I sounded harsh. It's fine to use AI, but it's best to first review the output and run the test manually. If you're not using it that's also fine, I just assumed so because your PRs are sometimes quite quick after creating an issue and the summary looks more descriptive than I would ever write manually.

<build>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we add a test that uses includes as well? Unless I am misremembering and there is such test already?

@krrish175-byte

Copy link
Copy Markdown
Contributor Author

@tgodzik: No worries at all, I completely understand what you are trying to say. I have a lot of respect for the work you do maintaining bloop, metals and other repos, and I really appreciate the time you take to review my PRs and guide me.

I'll definitely be more mindful about reviewing everything thoroughly and ensuring manual verification is solid :)

Regarding the test case: I’ve just updated the PR with a new test for as requested. Let me know if that looks good! Thanks again

@tgodzik tgodzik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@tgodzik tgodzik merged commit e778612 into scalacenter:main Jan 14, 2026
4 checks passed
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.

Incorrect classpath because INCLUDE field in pom file is ignored

2 participants