Issue
I have gradle multi-project that looks as follows:
-Project
|
|- common
|- moduleA
|- moduleB
moduleA is Spring Boot app and its gradle build file uses SpringBootGradle plugin. This module depends on common nodule.
moduleB is also Spring Boot app and its gradle build file uses SpringBootGradle plugin. This module depends on moduleA.
After I build my Project with gradle build I expect that moduleA.jar and moduleB.jar exist and they do. But when I try to run moduleB.jar I get an exception (Spring Boot initialization exception). As I found moduleB.jar contains lib directory with all dependencies from moduleA as well as moduleA.jar (which is packaged with dependencies also).
So what I need is to find a way to add moduleA plain jar as a dependency to my moduleB during the build.
Solution
You need to configure module A so that it can be used as a dependency:
bootRepackage {
classifier = 'exec'
}
This will mean that you end up with two jars. One without a classifier that can be used as a dependency, and one with a classifier that is the executable fat jar with dependencies nested inside it.
Answered By - Andy Wilkinson