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

skip non-class files in the exclusions processing for MergeJars #1125

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

vinnybod
Copy link
Contributor

@vinnybod vinnybod commented May 3, 2024

This is sort of an addendum to #1106 and #1107
In the previous PR, I added an exception for COPYRIGHT and NOTICE since it was the same kind of use case as the existing LICENSE exception.

The issue that I am having is that I have files that should be present in all of the jars being published in a repo that are not COPYRIGHT, NOTICE, or LICENSE. For example a project-version.properties file that contains info about the build.

Changing the readExcludedFileNames function to only process *.class files allows for these files to propagate to the final jar. It also still passes all existing test cases.

The only test for this functionality is specifically looking at .class files.https://github.com/bazelbuild/rules_jvm_external/blob/master/tests/com/github/bazelbuild/rules_jvm_external/jar/MergeJarsTest.java#L221

I am open to other solutions, but this seems to have fixed a lot of issues for my use case without breaking any existing functionality that is being tested for.

@shs96c
Copy link
Collaborator

shs96c commented May 7, 2024

How would this cope with multiple versions of the same file? Things like log4j config files, or other elements that are often found in the root directory of a jar, and that could (would!) cause problems.

@vinnybod
Copy link
Contributor Author

vinnybod commented May 7, 2024

This would still handle those duplicate files however the --duplicates flag is set, which defaults to last-wins. I added two additional tests to the pull request to show that behavior.

To me, this makes more sense than the existing behavior which is excluding files completely. I’m not 100% sure why the exclusions work the way they do. But, I don’t have the full picture of this tool, so please let me know me if I am missing anything.

Specifically, the case I am running into is with java_export. The lib that gets created has the files I expect, but then after the -project jar is generated, it is missing files.

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.

None yet

2 participants