I have a maven-built CDI-based Java SE app, which has a core module, and other modules.
Core has the persistence.xml and some entities.
Modules hav
I have a slightly different setup where I am placing persistence.xml in the WAR file but some of its dependencies includes @Entity annotated classed to include in the persistence unit.
I have solved my problem using Maven a bit like Adrian Shum described in #3, but using the element to include the jars to be scanned for @Entity annotations.
I added a property to my-web/pom.xml for each dependency including extra entities. All my jars are part of a Maven multiproject build so for me it looks like.
common-${project.version}.jar
foo-${project.version}.jar
I thereafter add the following to the persistence.xml
java:jboss/datasources/mysource
lib/${common.jar}
lib/${foo.jar}
...
Lastly I configure the maven-resource-plugin in web/pom.xml to replace the $expressions in persistence.xml with the properties set in the POM
src/main/resources
true
**/persistence.xml
src/main/resources
false
**/persistence.xml
...