Hello! I'm trying to embed and relocate some dependencies in a jar file with the maven-shade-plugin. I have a trivial example here that does this:
https://github.com/io7m/resolver-shade-example The compilation produces a com.io7m.resolver-0.0.1-embedded.jar file containing most of the dependencies except for a couple that I'd like the user to provide (logback, slf4j). All of the included dependencies are relocated to a package starting with "com.io7m.resolver.internal". The problem: I now want to insert a module-info.java file that exports only the com.io7m.resolver package (hiding the internal packages). I can't put this file in the source tree itself because then the IDE will complain endlessly that I've not "required" the external dependency packages. This is correct, but the compiler obviously can't know that by the time the jar is produced, all of those external packages will actually be internal to the module (due to shading) and therefore "requires" clauses are not... required. What's the recommended way to deal with this? The intended final module-info.java file is pretty trivial: module com.io7m.resolver { requires org.slf4j; exports com.io7m.resolver; } It seems like I'd need to compile the module-info.java against a fake source directory (to stop the compiler complaining that the module is empty) and then insert the resulting module-info.class file into the shaded jar file afterwards. This seems fairly ugly though. Is there a better way? -- Mark Raynsford | http://www.io7m.com
pgp60bNlL2pJb.pgp
Description: OpenPGP digital signature