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

Displaying warn level messages for file collisions #126

Closed
wants to merge 2 commits into from

Conversation

chapmajs
Copy link

We experienced problems in a recent project where Java property files were being left out due to collisions with other JARs in the project. In the course of debugging the issue, we tried the OneJar Gradle plugin which printed debug messages about these collisions. This PR adds the same functionality to the Shadow plugin.

With warnings about file collisions, it's trivial to add appropriate appending transformers to the Gradle task for the shadow JAR. One interesting thing we noticed with this was frequent collisions on META-INF/LICENSE, which has possibly interesting ramifications for some projects, e.g. anything that includes an Affero GPL license.

It was necessary to modify the visitedFiles data structure to allow storing the source JAR and file size without ripping through JAR files again. We provided several overloaded methods to allow insertion into visitedFiles.

@chapmajs
Copy link
Author

It appears that #102 attempts to overcome the symptom automatically, this PR would probably help end users identify those problems.

@johnrengelman
Copy link
Collaborator

Thanks for the contribution. I'll try and take a look soon on this (I'm pretty wrapped up in work at the moment though. It'll probably be awhile).

Could you take a look at adding a test for this? The test fixtures should give you access to the entire console output of the build and you should be able to parse it for the warning message.

@chapmajs
Copy link
Author

Tests added! Thanks for taking time to handle this PR.

@chapmajs
Copy link
Author

Is there anything preventing this PR from being merged in?

@@ -157,8 +157,25 @@ public class ShadowCopyAction implements CopyAction {
fileDetails.relativePath.pathString.endsWith('.zip')
}

private boolean recordVisit(RelativePath path) {
return visitedFiles.add(path.pathString)
private boolean recordVisit(path, size, originJar) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

please using typing on arguments.

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.

2 participants