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

Compare with Current View Page History

« Previous Version 40 Next »

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.

  1. Ensure that you have Java installed and in your path by running: java -fullversion
  2. 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
  3. 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
  4. Create a new directory you want to do your work in, then change to that directory from the console.
  5. 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.
  6. Change to the openjpa-trunk directory, which has already been created in the previous step.
  7. 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:

$ cd /tmp/

$ java -version

java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-112)
Java HotSpot(TM) Client VM (build 1.5.0_06-64, mixed mode, sharing)

$ mvn -v

Maven version: 2.0.9

$ svn --version

svn, version 1.4.3 (r23084)
   compiled Jan 18 2007, 07:47:40

$ svn co https://svn.apache.org/repos/asf/openjpa/trunk/

A  trunk/openjpa-lib
A  trunk/openjpa-lib/src
A  trunk/openjpa-lib/src/test
A  trunk/openjpa-lib/src/test/java
A  trunk/openjpa-lib/src/test/java/org
A  trunk/openjpa-lib/src/test/java/org/apache
A  trunk/openjpa-lib/src/test/java/org/apache/openjpa
A  trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib
A  trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/test
A  trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/test/AbstractTestCase.java

 ...

A  trunk/openjpa-persistence/pom.xml
Checked out revision 421381.

$ cd trunk/

$ mvn compile

[INFO] Scanning for projects...
[INFO] Reactor build order: 
[INFO]   OpenJPA
[INFO]   OpenJPA Utilities
[INFO]   OpenJPA Kernel
[INFO]   OpenJPA JDBC
[INFO]   OpenJPA JPA
[INFO]   OpenJPA JPA JDBC
[INFO]   OpenJPA XML Store
[INFO]   OpenJPA Slice
[INFO]   OpenJPA Aggregate Jar
[INFO]   OpenJPA Distribution
[INFO]   OpenJPA Persistence Examples
[INFO]   OpenJPA Integration Tests
[INFO]   OpenJPA Examples Integration Tests
[INFO]   OpenJPA JPA TCK Integration Tests
[INFO] ----------------------------------------------------------------------------
[INFO] Building OpenJPA
[INFO]    task-segment: [compile]
[INFO] ----------------------------------------------------------------------------

 ...

[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] OpenJPA ............................................... SUCCESS [0.000s]

[INFO] OpenJPA Utilities ..................................... SUCCESS [1:12.953s]
[INFO] OpenJPA Kernel ........................................ SUCCESS [13.219s]
[INFO] OpenJPA JDBC .......................................... SUCCESS [9.094s]
[INFO] OpenJPA JPA ........................................... SUCCESS [3.500s]
[INFO] OpenJPA JPA JDBC ...................................... SUCCESS [3.250s]
[INFO] OpenJPA XML Store ..................................... SUCCESS [0.140s]
[INFO] OpenJPA Slice ......................................... SUCCESS [0.719s]
[INFO] OpenJPA Aggregate Jar ................................. SUCCESS [0.250s]
[INFO] OpenJPA Distribution .................................. SUCCESS [0.344s]
[INFO] OpenJPA Persistence Examples .......................... SUCCESS [0.265s]
[INFO] OpenJPA Integration Tests ............................. SUCCESS [0.000s]
[INFO] OpenJPA Examples Integration Tests .................... SUCCESS [0.000s]
[INFO] OpenJPA JPA TCK Integration Tests ..................... SUCCESS [0.000s]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 44 seconds
[INFO] Finished at: Tue Sep 02 08:09:27 CDT 2008
[INFO] Final Memory: 11M/29M
[INFO] ------------------------------------------------------------------------


$ mvn package -DskipTests

[INFO] Scanning for projects...

...

[INFO] [assembly:attached {execution: bin}]
[INFO] Building zip: /tmp/openjpatestbuild/trunk/openjpa-project/target/site/
downloads/apache-openjpa-1.3.0-SNAPSHOT-binary.zip

... 


$ ls -lh openjpa-project/target/filtered-site/resources/downloads/

total 46985
-rw-r--r--    1 sutter pony3        9374808 Sep  2 08:14 apache-openjpa-1.3.0-SNAPSHOT-binary.zip
-rw-r--r--    1 sutter pony3       14680997 Sep  2 08:16 apache-openjpa-1.3.0-SNAPSHOT-source.zip

Executing various Maven build tasks

Running just the "TestPersistence" test case
mvn test -Dtest=TestPersistence
Running tests with Java 2 security enabled
mvn test -Penable-security
Building and running only the examples included in the distribution
mvn -DskipTests -Pexamples-profile integration-test
Building just the javadoc

First install the jars:

mvn install -DskipTests

Then build the javadoc:

mvn package -DskipTests -Pjavadoc-profile

The javadoc will be output to target/site/apidocs/index.html.

Building just the docbook documentation
set MAVEN_OPTS=-Xmx512m
mvn -f openjpa-project/pom.xml process-resources -Pdocbook-profile

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)
mvn compile -Djava14.jar=C:\Program Files\Java\j2re1.4.2_07\lib\rt.jar compile

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

  1. Checkout the source as described above
  2. Build the source using Maven as described above
  3. Create the Eclipse Metadata -
    mvn eclipse:eclipse
    
    • 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
      mvn eclipse:configure-workspace -Declipse.workspace=${path to your workspace} 
      
  4. Start Eclipse (3.2 - 3.4 SR2 are known to work) and create a new workspace
  5. 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
  6. 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
  7. 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:

  1. Open the Properties for openjpa-persistence
  2. Select Java Build Path --> Source
  3. Edit the openjpa-persistence/src/main/java --> Excluded setting to include the following:
    org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
    org/apache/openjpa/persistence/meta/CompileTimeLogger.java
    org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java
    

Eclipse with M2Eclipse plugin

  1. Checkout the source as described above
  2. Build the source using Maven as described above
  3. Start Eclipse (3.5 Galileo is recommended) and create a new workspace
  4. Good references for this M2Eclipse plugin (need to install the plugin into your Eclipse environment)
  5. 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.
  6. 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:

  1. Open the Properties for TRUNK-openjpa-persistence (or whatever your naming convention is)
  2. Select Java Build Path --> Source
  3. Edit the openjpa-persistence/src/main/java --> Excluded setting to include the following:
    org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
    org/apache/openjpa/persistence/meta/CompileTimeLogger.java
    org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java
    


  • No labels