Contents
Building OpenJPA
See Build and Runtime Dependencies for details on the required Java levels.
Maven
Command Line Builds
These instructions describe how to check out the current OpenJPA source code (from the Subversion source code management repository) and build it (using the Apache Maven 2 build tool). They are written for use from the console, and are known to work on Linux and Mac OSX. They are also reported to work from Windows.
- Ensure that you have Java installed and in your path by running: java -fullversion
- Install the build tool, Apache Maven 2.2.1 or later, from http://maven.apache.org/. If it is installed correctly, typing mvn -v from the console will result in the text Maven version: 2.2.1
- Install Subversion v1.4.x from http://subversion.tigris.org/. If it installed correctly, typing the following command should output help information: svn help or svn --version
- Create a new directory you want to do your work in, then change to that directory from the console.
- Check out the sources by running: svn co https://svn.apache.org/repos/asf/openjpa/trunk openjpa-trunk. It will check out the sources to a openjpa-trunk directory. More information on checking out the OpenJPA sources can be found on the Source Code page.
- Change to the openjpa-trunk directory, which has already been created in the previous step.
- Build OpenJPA by running: mvn package or better mvn install. The first time you run the build, many dependencies are automatically resolved and downloaded. It is common for dependency downloading to fail the first time, which will fail the build. If any of these dependency downloads fail, just re-run the command. You may also add the following to your ~/.m2/setting.xml file (see http://maven.apache.org/guides/mini/guide-mirror-settings.html)
#
<settings>
<mirrors>
<mirror>
<id>repo.mergere.com</id>
<url>http://repo.mergere.com/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings>
If any tests fail, and you want to ignore the failures, instead run:
mvn package -DfailIfNoTests=false
or
mvn package -DskipTests
An example session as as follows:
Executing various Maven build tasks
Running just the "TestPersistence" test case
Running tests with Java 2 security enabled
Building and running only the examples included in the distribution
Building just the javadoc
First install the jars:
Then build the javadoc:
The javadoc will be output to target/site/apidocs/index.html.
Building just the docbook documentation
The manual HTML will be output to openjpa-project/target/manual/manual.html.
Building with JDK 1.4 module verification (only for versions of OpenJPA prior to svn revision 640685)
Specifying the "java14.jar" system property will cause the JDK-1.4-dependent modules to be compiled with the value as the bootclasspath to the compiler. This can be useful to ensure that modifications and additions do not violate the JDK version restriction of the module. Since the runtime jar location is platform, version, and installation dependent, the exact location of the runtime jar will vary, which is why it needs to be manually specified.
Eclipse with Command-line Maven utilities
- Checkout the source as described above
- Build the source using Maven as described above
- Create the Eclipse Metadata -
- If this is the first project in your workspace to use maven artifacts you need to create a classpath variable named M2_REPO which contains the full path to your local repository. The eclipse plugin can do this for you with the following command
- Start Eclipse (3.2 - 3.4 SR2 are known to work) and create a new workspace
- Import the OpenJPA projects, by:
- Select File --> Import... --> General - Existing Projects into Workspace --> Next
- Select root directory = <svn checkout location above>
- Deselect the openjpa-examples project
- Press Finish
- A few fixups will be required to remove the errors that exist in the imported projects...
- openjpa-kernel -> Properties -> Java Build Path -> Source -> Add Folders
- add target/generated-sources/javacc
- openjpa-jdbc -> Properties -> Java Build Path -> Libraries -> JRE System Library -> Edit
- change this to a Java 6 JRE to remove these errors (see below if you can not use Java SE 6)
- openjpa-persistence -> Properties -> Java Build Path -> Libraries -> JRE System Library -> Edit
- change this to a Java 6 JRE to remove these errors (see below if you can not use Java SE 6)
- openjpa-persistence-jdbc -> Properties -> Java Build Path -> Libraries -> JRE System Library -> Edit
- change this to a Java 6 JRE to remove these errors (see below if you can not use Java SE 6)
- openjpa-examples. Open up src/main/java and select ReverseMapping folder. Right mouse click.
- Select Build Path -> Exclude
- For each imported project, you'll need to edit the build properties to remove an incorrect dependency:
- Project --> Properties --> Java Build Path --> Source
- Remove openjpa-project from the list of source folders
For Java SE 5 users, you will need to exclude some Java SE 6 specific classes by performing the following steps for the trunk source:
- Open the Properties for openjpa-persistence
- Select Java Build Path --> Source
- Edit the openjpa-persistence/src/main/java --> Excluded setting to include the following:
Eclipse with M2Eclipse plugin
- Checkout the source as described above
- Build the source using Maven as described above
- Start Eclipse (3.5 Galileo is recommended) and create a new workspace
- Good references for this M2Eclipse plugin (need to install the plugin into your Eclipse environment)
- Import the OpenJPA projects, by:
- Select File --> Import... --> General -> Maven Projects --> Next
- Select root directory = <svn checkout location above>
- All of the pom.xml files should be pre-selected for the svn checkout location
- You can affect the naming convention used for the generated Eclipse projects (one for each Maven module). Click on Advanced and fill in the Name Template field. I prefer "TRUNK-[artifactId]" since it helps with workspace organization, but it's your choice.
- Press Finish
- Note: You may get a popup internal error at the end of this Import processing. Not sure what the problem is, but it doesn't seem to affect the usage. This will probably get cleared up soon since Eclipse 3.5 is still quite new.
- A few fixups will be required to remove the errors that exist in the imported projects...
- openjpa-kernel -> Properties -> Java Build Path -> Source -> Add Folders
- add target/generated-sources/javacc
- openjpa-jdbc -> Properties -> Java Build Path -> Libraries -> JRE System Library -> Edit
- change this to a Java 6 JRE to remove these errors (see below if you can not use Java SE 6)
- openjpa-persistence -> Properties -> Java Build Path -> Libraries -> JRE System Library -> Edit
- change this to a Java 6 JRE to remove these errors (see below if you can not use Java SE 6)
- openjpa-persistence-jdbc -> Properties -> Java Build Path -> Libraries -> JRE System Library -> Edit
- change this to a Java 6 JRE to remove these errors (see below if you can not use Java SE 6)
- openjpa-examples. Open up src/main/java and select ReverseMapping folder. Right mouse click.
- Select Build Path -> Exclude
For Java SE 5 users, you will need to exclude some Java SE 6 specific classes by performing the following steps for the trunk source:
- Open the Properties for TRUNK-openjpa-persistence (or whatever your naming convention is)
- Select Java Build Path --> Source
- Edit the openjpa-persistence/src/main/java --> Excluded setting to include the following: