Skip to content
This repository has been archived by the owner on Jun 23, 2020. It is now read-only.

Allow patterns to match classes under META-INF #34

Merged
merged 1 commit into from
Apr 6, 2018

Conversation

cheister
Copy link
Contributor

@cheister cheister commented Apr 6, 2018

With Java9 you can have module classes under the META-INF directory of a jar. It will probably have unintended consequences to shade those classes in a jar but this change allows you to shade those classes.

@stuhood
Copy link
Sponsor Member

stuhood commented Apr 6, 2018

Is this speculative, or do you guys actually have a usecase for this? I wonder if it could have unintended consequences...

@cheister
Copy link
Contributor Author

cheister commented Apr 6, 2018

Now that I've tracked down the real issue it was a workaround for pantsbuild/pants#5671. So I could take it or leave it?

@cheister
Copy link
Contributor Author

cheister commented Apr 6, 2018

Ok, I updated this with a better test case. I don't think you would want to map classes under META-INF but you might want to remove them from the shaded jar.

Copy link
Sponsor Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

One minor concern, but I might not be understanding the usecase.

@@ -122,6 +122,10 @@ private static boolean checkIdentifierChars(String expr, String extra) {
if (expr.endsWith("package-info")) {
expr = expr.substring(0, expr.length() - "package-info".length());
}
// Allow patterns under META-INF if you want to match multi-release class files.
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

If this strips the prefix off, is the result that it will match classes with that name outside META-INF? Would a test that confirms that a META-INF/ pattern doesn't accidentally match something outside META-INF be good?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this method is only returning true or false if the identifier is valid it shouldn't affect what pattern is matched but I'll add a test anyway.

@cheister cheister merged commit a503426 into pantsbuild:master Apr 6, 2018
@cheister cheister deleted the all-meta-inf-patterns branch April 6, 2018 21:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants