How to copy a sub-project's jars and direct dependencies (Java 9-related)

(Kyle Downey) #1

I have found plenty of examples of how to copy a project with all its JAR dependencies to a directory, but this causes a problem with Java 9+ modules: a JAR can only load from one and only one place, so if I want a layout like:


and try to copy all of module1 and module2’s dependencies from sub-projects, I’ll get duplicates because module2 depends on module1, and module1 depends on boot: essentially Gradle “repeats” the dependencies at each module layer. Is there a smarter way to do this than a bunch of Copy tasks with excludes to “block” the transitive dependencies?

The current multi-project build.gradle can be found here: