I have a specific question regarding the location of the hibernate-annotations jar in my maven project.
My project consists of three modules. The modules Client and Server are both depending on the module Shared. Maven builds two packages for deployment: Client + Shared and Server + Shared.
Annotated Hibernate entities are located in the Shared module since I need to pass them between the client and the server (via RMI).
Now comes my problem. The hibernate-annotations.jar is used as dependency of the Shared module to allow compilation of the Hibernate entities. The library itself depends on hibernate-core. As result, I have the hibernate libraries in my deployed client application, even if I don't really need them there. The jars are quite big and I want to keep the client as slim as possible.
Are there some established techniques to avoid this problem? One that comes to mind would be to use XML based Hibernate configuration so I could move the Hibernate dependencies to the Server module, but I would like to stick to annotations.
Thanks.
You could exclude one or more transitive dependencies of the Shared dependency in the pom.xml of your Client. Here an example assuming the shared project has group ID "org.shared", artifact ID "shared" and version "0.0.1-SNAPSHOT":
<dependency>
<groupId>org.shared</groupId>
<artifactId>shared</artifactId>
<version>0.0.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</exclusion>
...
</exclusions>
</dependency>