Question

I have a maven multi-module project which builds, a common jar and a number of application jars (that depend on the common jar). I assemble each applications as a zip file. I put all the dependent jars in a lib directory in the zip file.

I notice that the applications are quite large (approx 60Mb) and that most of this relates to the lib directory jars. I also notice that each application has a similar set of jars in its lib directory (as the other applications). Since I used dependencyManagement in the parent pom, all the versions of the jars are the same in each lib directory of each application.

What I would like to do is to share a single lib directory between all the applications. Should I create a zip file with all the dependent jars in it ? and unzip this somewhere? and change the scope of the jars to provided?

I wonder if one single application had to change to use a different version of a certain jar.. Ideally I'd simply rebuild the zip of jars and redeploy and it would contain both versions of the jar so that both the existing applications and the newly patched application could be supported.

Any thoughts ?

I'd appreciate some advise on this?

I did search a bit and couldn't find an answer to this... Thanks for any pointers.

Was it helpful?

Solution

I solved this by creating a pom with packing of type pom and explicitly listed all the jars in the dependencies section (copy/paste from dependencyManagement section of the single parent pom). I set the scope to compile. I assemble this into a zip file.

In the parent pom I set the scope of all dependencies in the dep mgt section to provided. Each application now inherits this scope.

I will unzip the libs.zip into a particular directory and get each application to point to it (in JDK 6 you can set the classpath to include all jars in a directory).

Now each application is quite small in size.

Great. Job well done...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top