-
Notifications
You must be signed in to change notification settings - Fork 179
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
Manually relocate snakeyaml multi-release classes. #1008
Manually relocate snakeyaml multi-release classes. #1008
Conversation
The multi-release classes for the relocated snakeyaml dependency need to be relocated manually due to a bug in the Maven Shade plugin. The plugin only relocates the content but not the package structure itself. See https://issues.apache.org/jira/browse/MSHADE-406.
PR Summary
|
pom.xml
Outdated
<pattern>META-INF/versions/9/org.yaml.snakeyaml</pattern> | ||
<shadedPattern>META-INF/versions/9/net.datafaker.shaded.snakeyaml</shadedPattern> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious whether there is a more generic solution which could handle other versions once they appear...
Otherwise any new version will lead to the same issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be an (undocumented way) to do this, I am currently looking at the Maven plugin code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The follwing commit should address your concern. Now all versions of the org.yaml.snakeyaml
package are being relocated. Although new versions will not come around very often and I hope that the actual bug in the Maven plugin will get fixed sooner or later so that this workaround can be removed.
This is an undocumented feature of the Maven Shade plugin, see plugin code: https://github.com/apache/maven-shade-plugin/blob/master/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that in shaded classes (e.g. Logger) there is a package name
package META-INF.versions.9.org.yaml.snakeyaml.internal;
i.e. it contains -
in META-INF
which is not supported symbol in package names...
I wonder how it is supposed to work?
Where do you see this? Inside the packaged jar? It should be translated to the correct package name when packaging. The META-INF is only necessary to locate the correct folder. |
yes, inside the packaged jar |
It probably works because the relocation I added is only used to move the classes into the correct package. The package name inside the class files is not replaced since the provided relocation path (including META-INF) does not match. Since the buggy Maven Shade plugin has done the renaming already (but not the relocation into the correct package, see linked bug report), we should be on the save side. I agree that it is not a clean solution but the result is a working and correct multi-release jar. This workaround can be removed as soon as the bug in the Plugin is fixed. I can also confirm that with this fix, the issue is gone for our use case and datafaker is still doing its job. |
It seems that they are currently working on a fix: apache/maven-shade-plugin#202 |
thanks for checking |
The multi-release classes for the relocated snakeyaml dependency need to be relocated manually due to a bug in the Maven Shade plugin. The plugin only relocates the content but not the package structure itself. See https://issues.apache.org/jira/browse/MSHADE-406. This fixes #1007.