2 years ago
#45411
RE_OVO
Gradle shadowjar packages all submodules into a single jar
Original issue: https://github.com/johnrengelman/shadow/issues/744
I recently converted my project to a multi-module project, but I'm having trouble using shadowjar's minimize feature. Here is my project structure:
Root project 'shadow-jar-test'
+--- Project ':api'
\--- Project ':core'
This is a multi-module project, core
depends on the api
module, and both core and api have some third-party dependencies(For example Kotlin std library). And, I implemented these 2 modules in the root project's build script and want to package them into a jar.
The problem is, when I add minimize() to the shadowjar task, it reduces all my code, it seems that it thinks that the subproject is also a third-party dependency.
shadowJar {
relocate 'kotlin', 'lib.kotlin'
relocate 'org.jetbrains', 'lib.org.jetbrains'
// minimize will remove the :core and :api module?
minimize()
}
I also tried add exclude statement into minimize:
minimize {
exclude(project(":core"))
exclude(project(":api"))
}
This will indeed package core and api, but the third-party libraries that core and api depend on are still not packaged
Shadow Version
7.0.0
Gradle Version
7.1
Expected Behavior
Properly minimize dependencies
Actual Behavior
It also minimized my project code?!
Gradle Build Script(s)
I created a example project to reproduce it: https://github.com/re-ovo/shadow-jar-test
This is the root project build script: https://github.com/re-ovo/shadow-jar-test/blob/master/build.gradle
kotlin
gradle
gradle-plugin
gradle-shadow-plugin
0 Answers
Your Answer