Reputation: 1040
So I have this big spring boot project with hundreds of APIs and corresponding models. I was asked to seperate it into three different modules. Storefront, Order Management System and Utilities. As per my basic, plan I sorted, filtered and moved Storefront and OMS APIs to their corresponding projects. I moved all the model classes into Utilities, created a package, added this package to the local repository and included it as dependencies of Storefront and OMS. Further Iexported these two projects as a runnable jar with copying required libraries into a sub folder next to the generated jar. And I did this because the sub folder will include the package for Utilities, and if in future, I have to update something from Utilities, I could just replace this package and restart the server.
Everything is working fine, the problem is with the size of the final package. The jar size of the original project is 175 MBs. All three projects have similar .pom files. So all three project export to a size which is almost 175 MBs. And as I said, I included the package for Utilities in other two projects. So the size of the sub folder for Storefront and OMS became around 350 MBs.
Finally, my question is, is there any way to split a maven project into 3 different sub projects which can be built and deployed independently and, is there any way these 3 projects share a set of libraries which can be stored remotely and accessed by them independently so to decrese the size of the final runnable jar?
Upvotes: 0
Views: 325
Reputation: 35805
I think there are some deeper issues involved. If your artifact has 175MB and most of this are dependencies, than you have very very many dependencies.
So first of all, you should ask yourself, if all of those dependencies are really necessary. It is not unusual that people add a dependency just to use one simple class from that dependency. And this dependency than has a transitive burden. 175MB really calls for a deeper analysis of this fact.
Next, if you see you cannot really reduce the dependencies any more, you can split the project into several ones (like you started to do). But, then most of the dependencies should be in just one of the resulting projects. If all of your resulting projects use all of the dependencies, then these projects are all doing similar, probably overlapping things, which is not good.
Upvotes: 1