Describe your use-case which is not covered by existing documentation.
I've just spent a few hours pouring over whatever documentation I could find and permuting my build.gradle trying to get shadow to merge several META-INF/hk2-locator/default files in a way that doesn't break their syntax.
Getting ServiceFileTransformer to combine them was easy enough, but the empty lines between groups of entries in hk2-locator files are semantically significant, and ServiceFileTransformer does not preserve them.
The ResourceTransformers like ServiceFileTransformer will not work as expected as the duplicate resource files fed for them are excluded beforehand. However, this behavior might be what you expected for duplicate foo/bar files, preventing them from being included.
from configuration/merging
On my several passes through the documentation, I read this to mean that DuplicatesStrategy should not be used with ResourceTransformers that merge files, as they somehow interfere with eachother.
None of the usages I could find of the transformers appeared to combine append with duplicatesStrategy = DuplicatesStrategy.INCLUDE, and thanks to this section of the documentation counter-indicating combining duplicatesStrategy with "transformers like ServiceFileTransformer" I didn't think to try it.
I was finally working on just writing a bespoke transformer implementation when I got a strange feeling and decided to just try doing the opposite of what the docs seem to say here, and low and behold:
tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
filesMatching ('META-INF/hk2-locator/default') {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
append 'META-INF/hk2-locator/default'
}
was exactly what I needed.
The grammar of that paragraph from the docs is broken to the point where it doesn't clearly say anything, but at the very least, if it was meant to imply that we should use DuplicatesStrategy to merge files it's more than just a little ambiguous.
Reference any relevant documentation, other materials or issues/pull requests that can be used for inspiration.
No response
Are you interested in contributing to the documentation?
I'd write a pull request fixing the docs, but this whole experience has left me so confused that I'm still not sure I 100% understand the behavior here, beyond the fact that this specific incantation I came up with works. Am I missing something?
Describe your use-case which is not covered by existing documentation.
I've just spent a few hours pouring over whatever documentation I could find and permuting my
build.gradletrying to get shadow to merge severalMETA-INF/hk2-locator/defaultfiles in a way that doesn't break their syntax.Getting ServiceFileTransformer to combine them was easy enough, but the empty lines between groups of entries in hk2-locator files are semantically significant, and ServiceFileTransformer does not preserve them.
from configuration/merging
On my several passes through the documentation, I read this to mean that
DuplicatesStrategyshould not be used withResourceTransformers that merge files, as they somehow interfere with eachother.None of the usages I could find of the transformers appeared to combine
appendwithduplicatesStrategy = DuplicatesStrategy.INCLUDE, and thanks to this section of the documentation counter-indicating combining duplicatesStrategy with "transformers like ServiceFileTransformer" I didn't think to try it.I was finally working on just writing a bespoke transformer implementation when I got a strange feeling and decided to just try doing the opposite of what the docs seem to say here, and low and behold:
was exactly what I needed.
The grammar of that paragraph from the docs is broken to the point where it doesn't clearly say anything, but at the very least, if it was meant to imply that we should use DuplicatesStrategy to merge files it's more than just a little ambiguous.
Reference any relevant documentation, other materials or issues/pull requests that can be used for inspiration.
No response
Are you interested in contributing to the documentation?
I'd write a pull request fixing the docs, but this whole experience has left me so confused that I'm still not sure I 100% understand the behavior here, beyond the fact that this specific incantation I came up with works. Am I missing something?