I have a Maven project structure like this:
main (POM project)
|-ejb (POM project)
| |-data1 (EJB module)
| |-data2 (EJB module)
| |-ejb-jsf-converters (Java application)
|-web (POM project)
| |-... (A bunch of Web applications)
|-ear (POM project)
|-web1-ear (Java EE7 EAR project)
|-web2-ear (Java EE7 EAR project)
I can compile everything in the order data1, data2, ejb-jsf-converters, web and finally ear. After that I can deploy web1-ear and web2-ear and all works fine. But having to compile everything in a specific order is annoying. I want to be able to just compile main.
But I can't.
The problem is that I have a lot of entities in data1. And these entities of course have a lot of meta-model classes. To generate them, I have these 2 snippets in data1's pom.xml:
...
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.4.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.5</version>
<scope>provided</scope>
</dependency>
...
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<compilerArguments>-Aeclipselink.persistencexml=src/main/resources/META-INF/persistence.xml</compilerArguments>
<processors>
<processor>org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
</plugin>
...
When I compile main instead of data1, all of the sudden, persistence.xml cannot be found and no meta-model classes are generated or found. I can change
<compilerArguments>-Aeclipselink.persistencexml=src/main/resources/META-INF/persistence.xml</compilerArguments>
to
<compilerArguments>-Aeclipselink.persistencexml=ejb/data1/src/main/resources/META-INF/persistence.xml</compilerArguments>
and then I can compile the main project. But when I do that, I no longer can compile data1. Then it's data1 that cannot find persistence.xml and generate meta-model classes. Being able to compile main is great, but being forced to compile main each time I just want to compile data1 is a pain. Compiling main takes 10-15 times longer than compiling data1.
I know I can make it work by specifying the absolute path, instead of a relative path, but many different machines need to compile this. The absolute path will not be the same on all of them.
I thought about using an environment variable, but I'm not sure it will work very well in all cases. For example when the project is compiled by a Jenkins slave.
How can I make this work, so I can compile both main and data1 as I see fit?
Aucun commentaire:
Enregistrer un commentaire