Artifacts from dependencies can be excluded by declaring an element inside a But in this case it\'s needed to
I really needed to do this dirty thing... Here is how
I redefined those dependencies with scope test. Scope provided did not work for me.
We use spring Boot plugin to build fat jar. We have module common which defines common libraries, for example Springfox swagger-2. My super-service needs to have parent common (it does not want to do so, but company rules force!)
So my parent or commons has pom.
io.springfox
springfox-swagger2
${swagger.version}
com.google.guava
guava
io.springfox
springfox-swagger-ui
${swagger.version}
io.springfox
springfox-bean-validators
${swagger.version}
junit
junit
${junit.version}
org.apache.poi
poi-ooxml
${apache.poi.version}
And my super-service pom.
super-service
com.company
common
1
io.springfox
springfox-swagger2
test
io.springfox
springfox-bean-validators
test
io.springfox
springfox-core
2.8.0
test
org.springframework.boot
spring-boot-starter-web
junit
junit
org.apache.poi
poi-ooxml
This is size of the final fat artifact
82.3 MB (86,351,753 bytes) - redefined dependency with scope test
86.1 MB (90,335,466 bytes) - redefined dependency with scope provided
86.1 MB (90,335,489 bytes) - without exclusion
Also this answer is worth mentioning - I wanted to do so, but I am lazy... https://stackoverflow.com/a/48103554/4587961