You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Using the maven-antrun-plugin

You can use the maven-antrun-plugin to launch the OpenJPA enhancer task using ANT. The steps are nearly identical to the ones for Enhancing with ANT (again, you may not need to move the persistence.xml file to the build directory, but I did for this write-up).

      <build>
      <!-- Copy the persistence.xml file to the build dir -->
      <!-- You can skip this step if you put the persistence.xml in src/main/resources/META-INF instead of src/main/java/META-INF -->
      <resources>
          <resource>
            <directory> src/main/java </directory>
            <includes>
              <include> **/*.xml </include>
              </includes>
          </resource>
        </resources>
        <plugins>
    .....           
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.2</version>
            <executions>
              <execution>
                  <phase>process-classes</phase>
                <configuration>
                  <tasks>
                      <taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask" classpathref="maven.compile.classpath"/>
                      <openjpac>
                          <classpath refid="maven.compile.classpath"/>
                      </openjpac>
                  </tasks>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
    ....
      </build>

Using the openjpa-maven-plugin

There is a Maven plugin provided by the Codehaus project, which uses OpenJPA to enhance entities during a Maven build, available at http://mojo.codehaus.org/openjpa-maven-plugin/usage.html.

  • No labels