Shadow plugin and multi-release jars

Hi,
I’ve been using the gradle shadow plugin to shade some lucene 7 dependencies, which are multi-release jars, doing something along the lines of relocating ‘org.apache.lucene’ to ‘shadow.org.apache.lucene7’.

This has been working fine while I’ve been using Java 8, as the META-INF/versions class files are not used. Now that I’m migrating to Java 9 and 10, I am having trouble with the Java version specific class files located under META-INF/versions which are not being relocated.

I can’t work out how to get the shadow plugin to relocate the class files under META-INF/versions.

Any pointers on how this might be done?

Thanks,

Ted

Just to clarify, the release specific class files themselves under META-INF/versions appear to be correctly relocated, but the enclosing path hierarchy is not, so for example, for the Java 9 specific class:

  • org.apache.lucene.util.CharsRef, the Java 9 version in the original lucene jar is located at;
  • META-INF/versions/9/org/apache/lucene/util/CharsRef.class
  • class name in the class file is: org.apache.util.CharsRef

After creating the shadow version relocating org.apache.lucene to shadow.org.apache.lucene7:

  • shadow.org.apache.lucene7.CharsRef, the Java 9 version in the shadow jar is located at:
  • META-INF/versions/9/org/apache/lucene/util/CharsRef.class {NOT RIGHT]
  • META-INF/versions/9/shadow/org/apache/lucene7/util/CharsRef.class [EXPECTED?]
  • class name in the class file is correct: shadow.org.apache.lucene7.CharsRef

This was picked up while using ProGuard, which complains about the mismatch between the path hierarchy and the actual class name.

Cheers.