[MSHADE-252] - Make source shading respect package/class name excludes by kriegaex · Pull Request #88 · apache/maven-shade-plugin (original) (raw)

@kriegaex

Fixes MSHADE-252.

Until now, there was a naive global search + replace for mapping '' to '', even if the corresponding packages are to be ignored. This works for binary JARs, but was completely broken for source JARs.

See also my related comment in MSHADE-252: https://issues.apache.org/jira/browse/MSHADE-252?focusedCommentId=17314377&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17314377

With this fix, on the one hand string replacement in source files works for both "dotty" strings like "my.package.name.Foo" and "slashy" ones like "/my/package/name/resource.properties". On the other hand, source files are now being parsed '' match by match and for each match the excludes list will be checked and replacements only performed if the corresponding matched package name is not on the excludes list. This is of course slower than just a raw 'replaceAll(..)', but it produces correct results.