Establishing a Development Environment
There are two well established development environments that the SDO community use, Maven and Eclipse. To use the Eclipse IDE you must first establish a maven environment.
Getting Setup for Development (prerequisites)
Download the following:
Setting up for Maven Development
- Get your source tree set up locally
- Ensure that maven (mvn) is on your execution path
- Ensure that you have network connectivity (Maven has the capacity to retrieve dependencies from the internet while executing a build instruction)
- In a shell or command prompt ensure that you are in the <sdo-source-root> directory
- Issue the command "mvn", this will build the SDO API interface, implementation, tools, samples, plugin source code , run any tests, package the class files in appropriate jars and install the jars in a repository on your computer.
- You can now use the tools of your choice to explore, use and modify the SDO source code. If you have extracted your source tree using SVN you will be able to submit patches arising from your modifications to the SDO project by attaching patch files to JIRAs.
Setting up for Eclipse Development
Follow the instructions above for setting up a maven development environment
Having ensured you have network access to the internet, in <sdo-source-root> directory
execute the command mvn -Peclipse eclipse:eclipse
- Start up eclipse
- Switch to the Java perspective
- Right click in the Package Explorer frame on the root of the newly created project and select Properties => Java Build Path
- Click on the "Libraries" tab and select "Add Variable...", "Configure Variables ...", "New ..."
- Set Name to M2_REPO and Click on "Folder..."
- Navigate to the "repository" folder/directory (on Windows this is \Documents and Settings\<user>\.m2\repository, on Linux it is ~/.m2/repository) and click OK
- Now execute "File => Import ... => General => Existing project into workspace
- Click "Browse ..." Navigate to the <sdo-source-root> directory and click OK
- Select all projects and click OK
- When building is complete the projects should now have no errors
At this point you have seven separate projects each dependent on binary artifacts in your maven repository. Don't be tricked into thinking that
if you modify the sdo-impl project, that those changes will be picked up by the sdo-tools project. If you want this behavior then follow these steps
- In the package explorer pane of the Java perspective, Right Click on Properties and select the libraries tab
- Select the M2_REPO/org/apache/tuscany/sdo/sdo-api* library entry and click "remove"
- Select the Projects tab and click "Add..."
- Select the SDO API project and click OK
- If you plan to work in the tools project
- Select the "Order and Export" tab and select the sdo-api project and click OK (this means that the sdo-impl project will expose the interfaces of the sdo-api project, so that you don't have to import them into projects which depend on the sdo-impl project)
- Repeat the above instructions, removing the sdo-api and sdo-impl library dependencies from the tools project, and adding a project dependency for the sdo-tools project on the sdo-impl project
Digging into EMF
With EMF being such an integral part of SDO development, its often necessary to debug into the EMF code to understand what's going on. To do this you need to download an EMF SDK (runtime, source, docs) for EMF, SDO and XSD (Don't be confused by the presence of SDO; the version 1 API used to be developed at Eclipse, and it is this that is being downloaded, you can safely ignore it). You'll need the corresponding EMF version to the Tuscany SDO source code (Currently EMF 2.2.3 as at January 2008). Take a look for the <emfVersion> tag in the sdo/pom.xml file to discover the current version dependency. Extract the downloaded archive to somewhere on your computer.
- When eclipse opens up a .class file and presents you with an "Attach Source..." button, click it and the click "Variable ...", "New..."
- Create a variable, e.g. EMF_SRC and set the value to a folder within your extracted EMF archive, e.g. C:/Development/downloads/emf-sdo-xsd-SDK-2.2.3/eclipse/plugins
- Click OK to close the "Variable Selection" dialog
- In the "Source Attachment Configuration" Dialog, click "Extension ..."
- Navigate to the src.zip file corresponding to the class you are interested in. This will take a little bit of thought. Look at the package name for the class you are interested in and navigate to a zip file that would seem to correspond to that class, e.g. org.eclipse.emf.source_2.2.3.v200702131851/src/org.eclipse.emf.ecore_2.2.3.v200702131851/src.zip
- You should now be able to set breakpoints and observe execution behavior of the EMF code in the eclipse debugger