JUnit and multi-module Maven project with JPA
I've got two modules in my multi-module Maven project: mod1 and mod2
mod1 is the generic JPA gateway to establish a DB connection and provide EntityManagerFactory while mod2 contains the actual DAO classes.
Now, I've got a test case in mod2 which is using mod1 to provide a JPA EntityManagerFactory.
I've got my persistence.xml in mod1 obviously as both mod1/src/main/resources/META-INF/persistence.xml and mod1/src/test/resources/META-INF/persistence.xml obviously with two different config, one for production and one for tests.
When calling my unit test in mod2 I noticed persistence.xml is used from mod1/target/classes/META-INF/persistence.xml
This is bad as I want to use the one generated in mod1/target/test-classes/META-INF/persistence.xml with my test config.
I've got all my pom's properly set up, everything's working fine just this unit test misery is strange.
Any idea how to resolve this issue?
Thank you guys