mavendependenciesmyeclipse

Maven Common dependencies multiple projects exclude jar from war


We have multiple web projects(100+), custom jars and REST web service projects in our environment. We were using ANT to build with Jboss5.2.1 and I am trying to move to Maven with MyEclipse 2019 and deploy to a Tomcat server. All of the common jars required are in Jboss/server/default/lib and are added into the build path of the web project. We do not want the dependency jars to be packaged into the WAR files. With Maven, the dependencies get added to the war increasing the size of the war. We would like to have these dependencies like gson, poi, etc in a common place and refer to that using build path. Is that a possibility?

I did read about using system scope. But since that is deprecated and not suggested, I do not want to go that route. Setting up a local maven repository with a parent project also does not seem to be something that will work for us because I do not want the dependency jar in the lib folder of the WAR.

Is going with Maven even the right approach in this case? MyEclipse CI 2019 creates all web projects as Maven projects by default. So I will have to figure out a way to disable that if this is not the right build tool for us.

Having the dependency jars packaged into the WAR is something that will not be accepted here since the deployment team feels that bloats the size of each WAR unnecessarily. I am new to Maven and trying to setup the project the right way. Thank you for the help!


Solution

  • You want some common jars to be provided by the server at runtime and not be packaged into each war.

    So you have to do two things:

    This has the effect that the dependencies are available at compile time but are not bundled into the war.

    Beware, though, that having many common libraries makes it hard to update one of those.