We have a solution in which our user interface projects include quite a few business services using EJB client dependencies. The problem with this on Maven is that although the .jar client usually contains about 1-2 classes, they bring with them a complete dependency stack of the entire service application. It can become a little ugly when .ear files start to grow up to 50-100 MB of pop music, and from time to time inhibited errors appear due to irrelevant dependencies that make their way into the user interface application.
Of course, we can always eliminate dependencies on the client side, but then we need to write the same set of lines for each client project using these services and a lot of unnecessary repetition. In addition, people come up with the strangest error messages and use a lot of time to track them before recalling that they turned on some client bank and did not check what additional dependencies it makes to the equation.
Example:
<dependency> <groupId>fi.path.to.service</groupId> <artifactId>customermanagement-common</artifactId> <version>2.6</version> </dependency> <dependency> <groupId>fi.path.to.service</groupId> <artifactId>customermanagement-service</artifactId> <classifier>client</classifier> <exclusions> <exclusion> <groupId>fi.path.to.dependency</groupId> <artifactId>internal-dependency-#1</artifactId> </exclusion> <exclusion> <groupId>org.codehaus.castor</groupId> <artifactId>castor</artifactId> </exclusion> <exclusion> <groupId>fi.path.to.dependency</groupId> <artifactId>internal-dependency-#2</artifactId> </exclusion> <exclusion> <artifactId>internal-dependency-#3</artifactId> <groupId>fi.path.to.dependency</groupId> </exclusion> <exclusion> <artifactId>internal-dependency-#4</artifactId> <groupId>fi.path.to.dependency</groupId> </exclusion> <exclusion> <artifactId>internal-dependency-#5</artifactId> <groupId>fi.path.to.dependency</groupId> </exclusion> <exclusion> <artifactId>castor-xml</artifactId> <groupId>org.codehaus.castor</groupId> </exclusion> <exclusion> <artifactId>castor-codegen</artifactId> <groupId>org.codehaus.castor</groupId> </exclusion> <exclusion> <artifactId>castor-xml-schema</artifactId> <groupId>org.codehaus.castor</groupId> </exclusion> <exclusion> <artifactId>internal-dependency-#6</artifactId> <groupId>fi.path.to.dependency</groupId> </exclusion> </exclusions> <version>2.6</version> </dependency>
This is just one service client, which includes, imagine that you have several of them in several different applications, and you get an image, recording all the exceptions, every time itโs very annoying, and the POM of the project starts for a rather long time.
I would note the dependency as provided, but there are two dependencies that lead to runtime failure if they do not exist. Tell those that include another service call to another application with an external Exception class that for one reason or another has not completed inside the service project and will throw a ClassNotFoundException at runtime if not present.
Therefore, I know that it is possible to exclude / include classes from the ejb client during its generation by using the pom.xml specifications in the maven-ejb-plugin, but is there a way to exclude dependencies?
source share