As of this writing the OpenJPA Plugin provides 3 goals to cope with persistence-enabled classes in a project using Maven 2.
openjpa:enhance enhances the persistence-enabled classes in a project.openjpa:test-enhance enhances the persistence-enabled test classes in a project. This is typically bound to the process-test-classes phase.openjpa:sql creates a file which contains the SQL statements for creating or updating the database or directly create the schema in the database.openjpa:schema create the schema mapping XML file
All these OpenJPA Mojos expect the following resources to be present on classpath:
META-INF/persistence.xml, orMETA-INF/openjpa.xml
OpenJPA documentation is available here.
Below is an OpenJPA plugin configuration example.
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<includes>com/myproject/entities/**/*.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
<!-- Pass additional properties to the Plugin here -->
<toolProperties>
<property>
<name>directory</name>
<value>otherdirectoryvalue</value>
</property>
</toolProperties>
</configuration>
<executions>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>openjpa:enhance mojo will automatically be called in the process-classes phase.
From the command prompt/terminal window.
mvn openjpa:enhance
mvn openjpa:sql
mvn openjpa:schema