maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Raynsford <>
Subject Inserting a single module-info after shading
Date Sat, 03 Feb 2018 13:43:18 GMT

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:

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 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 file is pretty trivial:

  module com.io7m.resolver {
    requires org.slf4j;
    exports com.io7m.resolver;

It seems like I'd need to compile the 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 |

View raw message