I have a Maven project set up that has a parent and two child modules:
parent
business
support
All of my JPA entities are in the support module. I've decided I want to use JPA metamodel classes to provide type safety when I use the Criteria API. I made changes to the pom.xml for the support module (see below) and the metamodel classes are being created correctly in support/target/metamodel
when I build from the command line using mvn clean install
. Builds work and deployable artifacts work when deployed.
The issue is that when I follow the instructions here (which mirrors many other places) on how to set up Eclipse to build the metamodel classes, Eclipse doesn't seem to do anything. It creates the support/target/metamodel directory but there's never anything in it. I've cleaned inside Eclipse, from the command line using mvn clean
, done Maven->Update Project multiple times but nothing seems to work.
What am I missing?
Here's what my support project's properties look like.
The relavant section of my support module's pom.xml is:
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<!-- source output directory -->
<outputDirectory>target/metamodel</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/metamodel</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Version information:
Red Hat JBoss Developer Studio Version: 10.2.0.GA Build id: GA-v20161125-1418-B55 Build date: 20161125-1418
Java 1.8.0_112
Maven (command line): 3.3.9
Maven (Eclipse - m2e): 1.7.120161104-1805 embedded version 3.3.9
This is the setup that has worked for me.
I did not use the org.bsc.maven:maven-processor-plugin, rather set up the maven-compiler-plugin for annotation processing. The issues mentioned in the instructions, i.e. MCOMPILER-62 and MCOMPILER-66, are now closed, so I see no reason why to bother with the org.bsc.maven:maven-processor-plugin.
Another notable difference is the "Factory Path", in the Eclipse configuration.
pom.xml
A minimal setup to get started. Note the maven-compiler-plugin configuration.
You may want to run it once by hand or download hibernate-jpamodelgen by hand (e.g.
mvn dependency:get -Dartifact=org.hibernate:hibernate-jpamodelgen:5.2.5.Final
), so that the JAR is available for the Eclipse configuration.Eclipse configuration
target/generated-sources/annotations/
(this is where Maven puts them by default)hibernate-jpamodelgen
version will probably vary):org/hibernate/hibernate-jpamodelgen/5.2.5.Final/hibernate-jpamodelgen-5.2.5.Final.jar
javax/persistence/persistence-api/1.0.2/persistence-api-1.0.2.jar