Reputation: 15193
Where I work, each project is represented by a single JAR file. There are a set of database tables that are used for each project. Each of these projects have a Hibernate config and util inside that JAR, including the Entities.
I am now working on a project that will actually be using another project's database tables and thus, its Entities.
The issue I run into is that when I include the JAR as a dependency (through Maven), the main project's Hibernate config files are ignored and use the ones included in other project's JAR. This causes mapping issues with Entities and such, as you can imagine.
My question is: Is there way to include the other JAR file as a dependency yet ignore the Hibernate config files? Or at least make it use the ones in the main project?
I am trying to avoid duplicating the Entities and such as these tables may be altered in the future and would rather make changes in one project than several.
Thank you again for your help! Much appreciated!
Upvotes: 0
Views: 551
Reputation: 1804
1)As the jars used as a dependency are jars from your own projects, what about generating these jars without the files that are causing this conflict inside it?
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<configuration>
<excludes>
<exclude>**/somethingtoexclude/*</exclude>
</excludes>
</configuration>
</plugin>
...
</plugins>
</build>
...
</project>
2)If you don't like the idea about generating the jar without the files you want to ignore, you can remove it from generated jar file by using TrueZip Maven Plugin:
http://mojo.codehaus.org/truezip/truezip-maven-plugin/index.html
Example: http://svn.codehaus.org/mojo/trunk/mojo/truezip/truezip-maven-plugin/src/it/remove-file-in-jar-under-war/pom.xml
Upvotes: 1