Jump to: navigation, search

EclipseLink/Building

Git Structure

EclipseLink code has migrated from SVN to Git. The SVN repository has been split into several repositories. The repository list, descriptions, and urls can be found at: http://git.eclipse.org under the EclipseLink project list.

Runtime

The below is a description of the content of the directories. Note: All projects are Eclipse PDE projects and therefore classpath dependencies are defined in the manifest rather than the project metadata.

Plugins

The plugins directory contains all the common dependencies needed by all the projects. You can make use of them by either importing the Eclipse projects for all the depenencies or by making the bundle jars (all the jars) in this directory available to Eclipse's target platform. You can do that by adding a directory that contains those jars to your Target Platform under "Preferences -> Plug-in Development -> Target Platform", or by copying them to your Eclipse installation's plugin's directory.

The following dependencies can also be obtained from Orbit.

  • commonj.sdo 2.1.1
  • javax.activation 1.1.0
  • javax.mail 1.4.0
  • javax.persistence 1.0.0
  • javax.servlet 2.4.0
  • javax.wsdl 1.6.2
  • javax.xml.bind 2.0.0
  • javax.xml.rpc 1.1.0
  • javax.xml.stream 1.0.1
  • javax.xml.ws 2.1.0
  • org.apache.ant 1.7.0

Instructions about getting bundles from Orbit

Foundation

  • org.eclipse.persistence.core - All other EclipseLink components depend on this bundle. You will need to import this project to work on other EclipseLink components. All other components can be imported separately.
  • org.eclipse.persistence.oracle - extensions that require Oracle-specific libraries for compilation. If you do not have the required oracle libraries, you can get the compiled classes since they are checked in. This bundle is only used for advanced Oracle-specific functionality and not required unless you are using that functionality.
    • The oracle bundle requires that you configure the oracle target within your Eclipse. To do that, you will need to do the following:
      • Find the target.oracle directory in foundation/targets
      • Obtain the Oracle dependency jars and put them into oracle.libs folder. There is a list of them in the manifest found in oracle.libs. Note: These are not currently available in open-source format and you will have to obtain them from Oracle
      • Import the target.oracle directory and its contents into Eclipse as a Plug-in fragment

JPA

  • org.eclipse.persistence.jpa - EclipseLink's JPA support
  • plugins - The additional dependencies for JPA support

MOXY

  • org.eclipse.persistence.moxy - EclipseLink's Object-XML support
  • plugins - The additional dependencies for Object-XML support

SDO

  • org.eclipse.persistence.sdo - EclipseLink's SDO support
  • plugins - The additional dependencies for SDO support

DBWS

  • org.eclipse.persistence.dbws - EclipseLink's Database Webservice support
  • plugins - The additional dependencies for DBWS support

Build

Importing the projects into Eclipse will build the class files for the PDE projects. Most functionality will be accessible after those builds. Ant files are also provided both for use in a non-Eclipse IDE, and for commandline use. If you want to do a complete build of the EclipseLink artifacts, the steps are outlined In the "building with Ant" section below.

Building with Ant

Ant is used to drive all builds for the EclipseLink Project. Furthermore, it is assumed that EclipseLink will be built (ant tested) in environments other than the Eclipse IDE (PDE build). Therefore, the Ant buildfiles are designed to be used from many entry points with varying configurations. However, starting with 2.4, we have moved to a manifest-first approach to build our OSGi bundles. Therefore, rather than using BND to generate the OSGi manifest post build we are using Tycho (a maven plugin) to generate our OSGi bundles.

Below are the steps to setup for and then run a basic build of EclipseLink using the Ant buildfiles from the trunk.

Environment Setup

Most of the required dependencies are already existent in one of the previously discussed plugin folders. However, there are some third-party files that are not supplied. Specifically:

  • Ant 1.9.x for 2.6.0, Ant 1.7 for earlier versions.
    • Our build scripts don't work properly under 1.8.
    • If not already installed, you will need to download and install it.
  • Maven 3 for EclipseLink 2.4+ (Tycho requires Maven 3 functionality).
    • If not already installed, you will need to download and install it.
  • Make sure you have an "ANT_HOME", "M2_HOME" and "JAVA_HOME" environment variables pointing to appropriate folders.
  • Junit 4.11 (or higher)
  • JMockit 1.10
  • Any library licensed under an agreement that is not EPL or Eclipse approved. This includes Oracle libraries and 3rd party libraries needed to compile specific extensions
  • BND tool (2.3.x and earlier only)- we use bnd to generate our OSGi plugins in EclipseLink 2.3.x and earlier. Version .366 or later should work fine if placed in the extension.depend.dir or the buildsystem dir. In addition, if bnd is not available the build will attempt to generate meaningful OSGi manifests, but there are known shortcomings and issues with this approach.
    • Add the following entry to your user-dir/build.properties
      • bndtool.jar=bnd-0.0.384.jar as of 20100513
      • bndtool.lib=bnd-0.0.384.jar as of at least 2.4.2


The build provides mechanisms to incorporate these dependencies outside of Git. build defaults: The build assumes certain defaults for dependencies. These can be overridden, but are provided to allow minimal configuration setup.

  • external dependency location: The build assumes that all dependant libraries external to Git are stored in one of two default locations.
  • extensions.depend.dir: This property defines where external dependencies can be found. (default: .\trunk\..\extension.lib.external)
  • oracle.extensions.depend.dir: This is a legacy property for compatability with Oracle testing scripts. It is used to define the location of Oracle specific jars. (default: .\trunk\..\extension.oracle.lib.external)
  • library properties: Most dependant libraries are defined using a property definition that can be overridden
Overriding Defaults

Basic Setup

  • It may be necessary to create a user specific properties file to override the default values in <trunk>/build.properties. To do so, create a build.properties file in your user home directory (usually C:\Documents and Settings\<username> on windows). Variables commonly needing redefinition in it are:
    • For build:
    • For Test
      • jdbc.driver.jar=<full path to your JDBC driver>
      • db.driver=<classname of your JDBC driver>
      • db.url=<JDBC url of your DB>
      • db.user=<db username>
      • db.pwd=<db password>
      • (optional) db.platform=<EclipseLink Database Platform to use> - this is only necessary if EclipseLink does not properly dectect you DB with its database detection
  • Open a command prompt in your checked out trunk directory
  • Run "ant" (or "ant -f antbuild.xml" in 2.4 or later) for a full build of all core and test code
  • or
  • use the "build-eclipselink-jar" task for a full build of only core code

These commands will build the Runtime and/or the tests. Tests can also be run by adding a test execution target (like test-srg).

Note: Several DBWS component's build files are dependant upon JDK 1.6 (JDK 5 can be used but these components won't build)

Updating dependencies

In order to update EclipseLink's dependencies, take these steps:

  1. Prepare the dependency bundle. All product dependencies need to be OSGi bundles: so they need an OSGi manifest, and to be named appropriately: <bundleprefix>_<bundleversion>.<builddate>.jar.
  2. Verify the bundle by building the EclipseLink with it:
    1. Override the default remote compdeps setting to "local.compdeps=true" in your $home/build.properties file.
    2. Add the new bundle to /plugins or /<module>/plugins (as appropriate).
    3. Update antbuild.xml in buildsystem/compdeps.
    4. Update features.xml in buildsystem/compdeps/org.eclipse.persistence.compdeps.
    5. Update your module's MANIFEST.MF file to Import-Package your new dependency.
  3. Once your plugin passes the build, you need to create a CQ (e.g. https://dev.eclipse.org/ipzilla/show_bug.cgi?id=8334). If you are on a tight schedule, I recommend doing this step ahead of the others, since it may take some time before the CQ is approved.
  4. When the CQ is approved, create a bug on eclipse (e.g. https://bugs.eclipse.org/bugs/show_bug.cgi?id=438761) and submit a patch containing the changes.
  5. After the patch is pushed, contact the EL Releng team and ask them to update the p2 index.

For more detailed description see:

Testing

Tests can be run through Ant or in Eclipse

From Ant

In the trunk directory, you can use the following targets to run tests:

  • test-srg - Basic "smoke tests"
  • test-lrg - Full test model - must be run sucessfully on either MySQL or Oracle before checking in any changes to core classes
  • test-core - subset of tests just for the core
  • test-core-srg - smoke tess for the core
  • test-jpa - runs JPA tests - required prior to check-in for any changes to JPA included in "test-lrg"
    • JPA tests require some artifacts from the build in order to be able to run. There are two ways to get them.
      • Run the full build as indicated above
      • From the org.eclipse.persistence.jpa directory, run "ant"
    • This will create a directory required by the tests and the jars that contain the models. You only need to rebuild if you are adding or subtracting from the models (Package org.eclipse.persistence.testing.models.jpa and its subpackages).
  • test-wdf - runs the "WDF" JPA test suite (JPA tests contributed by SAP (Walldorf, Germany)).
  • test-moxy - runs MOXY tests - required prior to check-in for any changes to MOXY included in "test-lrg"
  • test-jaxb - required prior to check-in for any changes to JAXB included in "test-moxy"
  • test-oxm - required prior to check-in for any changes to OXM included in "test-moxy"
  • test-sdo - required prior to check-in for any changes to SDO included in "test-lrg"

From Eclipse

The following directories contain projects with tests

  • foundation/eclipselink.core.test - the core testing for EclipseLink
    • Testing Browser.launch - runs legacy test browser. Requires definition of JDBC_LIB classpath variables.
    • SRGTestModel.launch - runs the SRG. Requires definition of JDBC_LIB classpath variable
    • LRGTestModel.launch - runs the LRG. Requires definition of JDBC_LIB classpath variables.
  • foundation/eclipselink.extension.oracle.test - the testing for EclipseLink's Oracle-specific functionality.
    • Contains Testing Browser (Oracle).launch - Launches Legacy test browser in a manner that can run Legacy Oracle tests
  • jpa/eclipselink.jpa.test - the JPA tests for EclipseLink
    • See the description of the test-jpa target above for a prerequisite.
    • FullRegressionTestSuite.launch - runs JPA tests
      • Needs DB properties to run. either of the following can be done to give the DB properties:
        • Add a JVM argument: -Dtest.properties=<full path to build.properties in your user home>
        • update the test.properties file in jpa/eclipselink.jpa.test directory to point at correct DB
    • Testing Browser (JPA).launch - Launches Legacy test browser in a manner that can run JPA tests through that browser
      • Note: Recompilation of eclipselink.jpa.test test jars are required only if new classes were added/deleted since the last build.
  • jpa/eclipselink.spring.test - Spring specific JPA testing
  • moxy/eclipselink.moxy.test - MOXY testing
  • sdo/eclipselink.sdo.test - SDO testing
  • dbws/eclipselink.dbws.test - DBWS Testing

Minimum GIT projects for JPA or Core EclipseLink project Development and Testing

  • The following import screen capture from Eclipse 4.4 details the minimum projects you will need in order to do JPA or Core development in Eclipse.

Eclipselink-projects-corejpa.png

  • Before importing any test project into Eclipse, make sure you run full Ant build in order to let Eclipse resolve local test related dependencies
  • The following screens details the minimum test projects related to JPA and/or Core development in Eclipse.

Eclipselink-projects-corejpa-tests.png

  • Note: Also add the org.eclipse.persistence.moxy project (a requirement of eclipselink.jpa.test)
  • Note: Also define "ECLIPSELINK_HOME" classpath variable (Java | Build Path | Classpath Variables) pointing to your local Git clone root folder

Projects and Dependencies

When using the Eclipse IDE - a Luna or later EE version is required. See the Eclipse download site for information http://www.eclipse.org/downloads

All current dependencies can be found in the manifests for the PDE projects or in the bundles or in Problems view in Eclipse IDE.

Alternative IDEs

IntelliJ IDEA

This guide has been built using IntelliJ IDEA version 13 on Windows.

Prerequisites

Downloading eclipselink sources

Under VCS menu, select Checkout from Version Control and Git version control system. In the dialogue window that opens, enter git@orahub.oraclecorp.com:fmw-infra-toplink/eclipselink-runtime.git URL, fill in Parent Directory and Directory Name fields and click the Clone button. This process may take a while to complete.

Git clone IDEA.jpg

- For Parent Directory and Directory Name combination it is advised to not enter a long path in case of importing the project in a Windows system. A Parent Directory of C:\dev and Directory Name of eclipselink is enough.

- You should click Test to verify connection settings. In case of failure, check whether a proxy server should be used. It should be enough to select Auto-detect proxy settings under IDE Settings - File menu -> Settings -> IDE Settings -> HTTP Proxy -> Auto-detect proxy settings.

Setting up IDEA project

After downloading sources, a dialogue appears to create an IntelliJ IDEA project from the source files downloaded. Select Import project from external model and Eclipse. Clicking Next will initiate a scan of source files and a list of available projects will be displayed. Click Unselect all and select the following projects:

  • eclipselink.core.test
  • eclipselink.jpa.modelgen.test
  • eclipselink.jpa.test
  • eclipselink.moxy.test
  • org.eclipse.persistence.core
  • org.eclipse.persistence.jpa
  • org.eclipse.persistence.moxy
  • org.eclipse.persistence.moxy.dynamicxjc
  • org.eclipse.persistence.nosql

- You can import additional projects at any time selecting Import Module… dialogue under File menu

You will then be asked to select the project SDK. Select a Java 7 or Java 8 SDK and click Finish. At this point IDEA will create an ECLIPSE library. You need to provide the path to the eclipse installation. For ECLIPSELINK_HOME and MAVEN_REPOSITORY path variables, enter the project root directory and path to .m2/repository (M2_HOME) respectively.

Configuring project

Under File menu, select Project Structure. Inside Project panel, Change Project language level to 7.0.

Project sdk.jpg

Inside Modules panel, for every project module you need to change Module SDK to Project SDK and click OK.

Module dependencies.jpg

- (Language level change will require a project re-import to apply)

At this point, we need to run an ant build for test dependencies to be created.

Initially, a folder needs to be created at the same level as the project root called extension.lib.external (<project root>/../extension.lib.external). Files hamcrest-core-1.3.jar and junit.jar (a file rename may be needed) will need to be copied to that location.

Then, a user specific properties file needs to be created in the user home directory. To do so, create a build.properties file in your user home directory (usually C:\Documents and Settings\<username> on Windows) adding the following line:

junit.lib=<path to extension.lib.external>/junit.jar:<path to extension.lib.external>/hamcrest-core-1.3.jar

Now, in Project panel, find antbuild.xml file and right click, selecting Add as Ant Build File. Build targets will appear in Ant Build panel.

Ant panel.jpg

Double click build target and wait for the build process to finish.

Build messages.jpg

- (You can check the progress of the build in Messages panel)

After build has finished successfully, open Project Structure dialogue again and correct broken jar paths for eclipselink.jpa.modelgen.test module. For every broken path, click Add button and find the applicable jar file under <project root>/jpa/eclipselink.jpa.test. After adding the correct file, you may Remove the broken link.

Jpa test dependency.jpg

For org.eclipse.persistence.core module, click Add and select Jars or directories. Under <project root>/plugins, select the following files:

  • javax.persistence_2.1.0.v201304241213.jar
  • org.eclipse.persistence.antlr_3.2.0.v201302191141.jar
  • org.eclipse.persistence.jpa.jpql_2.6.0.qualifier.jar

For org.eclipse.persistence.jpa module, click Add and select Jars or directories. Under <project root>/jpa/plugins select javax.persistence_2.1.0.v201304241213.jar and under extension.lib.external select ant.jar.

For org.eclipse.persistence.moxy module, click Add and select Jars or directories. Under <project root>/plugins, select the following files:

  • javax.validation_1.1.0.v201304101302.jar
  • jaxb-core_2.2.11.v201407311112.jar
  • jaxb-xjc_2.2.11.v201407311112.jar

For org.eclipse.persistence.nosql module, click Add and select Module Dependency. Select module org.eclipse.persistence.core and click OK.

For eclipselink.jpa.test module, click Add, select Jars or directories and select the path to hamcrest-core-1.3.jar and click OK.

At this point you should be able to select Make Project under Build menu without errors.

Directly importing IDEA project

Instead of setting up eclipselink project from scratch, there is also the possibility of importing eclipselink IDEA project found within the project source files.

Under File menu, click Open and select the project root directory. This will import a project structure similar to the one described in the steps above. Since additional project modules are configured in this case, as a prerequisite, there is needed an existing Oracle Database installation. After installing the database, along with extension.lib.external folder, an additional extension.oracle.lib.external folder will need to be created. This folder will need to contain the following dependencies from the database installation:

  • dms.jar (<database home>/oc4j/lib)
  • ojdbc7.jar (<database home>/jdbc)
  • sdoapi.jar (<database home>/md/jlib)
  • ucp.jar (<database home>/ucp/lib)
  • xdb.jar (<database home>/RDBMS/jlib)
  • xmlparserv2.jar (<database home>/LIB)

When loading up the project, IDEA will display a warning about ECLIPSELINK_HOME, EXTENSION_LIB_EXTERNAL and EXTENSION_ORACLE_LIB_EXTERNAL variables. For fixing this, you may click on the error message or navigate to Settings under File menu and select Path Variables under IDE Settings. Enter the path to the project root and the paths to extension.lib.external and extension.oracle.lib.external folders respectively and click OK.

Under File menu, select Project Structure option. In Project section, you need to select an SDK as the Project SDK or setup one if none exists.

Running unit tests

You can either run unit tests using the applicable ant build script targets (test-srg, test-lrg) or creating run configurations for the test groups you wish to execute.

Test using ant targets

For running the unit test ant targets, you will need to provide the path to the test.properties file to use. Right click on the ant file to edit under Ant Build section and select Properties. Under Execution tab, you need to add the following entry to the Ant command line field: -Dtest.properties=<path_to_file>.

Ant properties.jpg

- (The path is relevant to the project configuration file. This will be the project root.)

After setting up the test property file to use, clicking on any test target (test-srg, test-lrg etc.) will start executing the unit tests for that target. You may follow the test output under Messages panel.

Test using build configurations

For creating test configurations, under Run menu, select Edit Configurations… option. Click on Add New Configuration (the green plus sign on the top left corner) and select JUnit from the drop down menu. In Configuration tab, select Class if you are planning to run a single test/test suite, otherwise Pattern if you are planning to execute multiple test/test suite classes at once.

Run configuration.jpg

In VM options section, you should add the following entries:

  • -Xmx1024M
  • -Djava.security.manager
  • -Djava.security.policy=($MODULE_DIR$/)<path to permissions file>
  • -Dtest.properties=($MODULE_DIR$/)<path to test.properties file>

- (It is advised to enter a path relative to the module directory, although an absolute path is acceptable as well.)

As the Working directory, enter $MODULE_DIR$\<path_to_run_folder> and select the module you wish to execute tests on for Use classpath of module field. In Before launch section, you may add ant targets to execute prior to running the tests (clean, build, clear-db). Click OK to leave the dialogue.

It is important at this point to setup the classpath for running unit tests. Under File menu, select Project Structure option. In Modules section, for every module the tests of which you need to execute, you need to enter the jdbc client jar to use with a Runtime scope. You then need to setup the rest of the classpath. For module eclipselink.core.test for example, you need to include paths to /run folder, eclipselink-coretest-framework.jar and eclipselink-core-tests.jar within the module directory, as well as the path to tools.jar JDK library (JAVA_HOME/lib).

Eclipselink.core.test classpath.jpg

At this point, you should be able to select the configuration to execute and click on Run or Debug. If you have selected to run some ant targets prior to the tests, you may monitor their progress in the Messages panel. When the tests start executing, the Run or Debug panel will automatically expand to display the tests progress.

For being able to run tests simply by right clicking on the test target, you may alter the default JUnit configuration. Under Run menu, select Edit Configurations… option. Expand Defaults and select JUnit. Enter VM options, Working directory and Before launch configurations as advised above and click OK. Provided that the module classpath is correctly setup as advised above, you should now be able to right click a test target and select Run <target_name>.