Developer's Tutorial for Cytoscape 3 on Eclipse: Rev. 1.1
Status
Document revesion 1.0 release: KeiichiroOno DateTime()
Document revesion 1.1 release. Fixed minor issues based on feedback: KeiichiroOno DateTime()
Introduction
This is a tutorial document to learn how to run and develop Cytoscape 3 with Eclipse PDE and other Eclipse plugins.
Procedure
Setting Up Your Environment
To develop Cytoscape 3 on Eclipse, you need to install several software packages.
Java Development Kit
You need to install JDK version 5 or 6.
Maven
Although you will use most of the functions from Eclipse IDE, it is better to install command line version of Maven in case you need to test your code from terminal. Also, internally this version of Maven will be used by Eclipse (will be described later).
[http://maven.apache.org/download.html Download Maven]
[:MavenInfo:Maven Tutorial]
- [:Cytoscape_3.0/Eclipse/M2EclipsePlugin:Introduction to Maven Integration for Eclipse]
From terminal, type mvn --version and if you see something like the following, you are ready to use Maven:
[kono@beaujolais core]$ mvn --version Maven version: 2.0.9 Java version: 1.5.0_15 OS name: "linux" version: "2.6.9-67.0.20.elsmp" arch: "i386" Family: "unix"
Eclipse
- attachment:eclipse_plugins0.png
This tutorial is based on the latest version of Eclipse 3.4, called Ganymede. Several distributions are available on [http://www.eclipse.org/downloads/packages/ Eclipse web site]. In this tutorial, we use Eclipse for RCP/Plug-in Developers version 3.4. This distribution includes PDE (Plugin development environment).
Eclipse Plugins
- attachment:eclipse_plugins1.png
Subversion Client (Subclipse)
Cytoscape 3 source code is managed by [http://subversion.tigris.org/ Subversion]. To access the repository, you need to install subversion client for Eclipse. In this tutorial, I'll use [http://subclipse.tigris.org/ Subclipse]. You can install the plugin from the eclipse's update manager. Do not forget to install SVNKit. Otherwise, you will get an error message when you try to check out repository ("Unable to load default SVN Client")
You can install the Subclipse plugin from Help > Software Updates... Click Available Software tab and add this URL by pressing Add Site button: http://subclipse.tigris.org/update_1.4.x
PAX Cursor
[http://wiki.ops4j.org/confluence/display/ops4j/Pax+Cursor PAX Cursor] is an Eclipse plugin developed by [http://wiki.ops4j.org/confluence/display/ops4j/Open+Participation+Software+for+Java OPS4J] developers. Basically, it is an Eclipse integration for [http://wiki.ops4j.org/confluence/display/ops4j/Pax+Runner PAX-Runner]. By this plugin, you can run set of bundles on multiple platforms including Felix, Equinox, and Knopflerfish.
To install this Eclipse plugin, just follow the standard plugin installation procedure discussed above.
PAX Cursor Eclipse Update Site - http://www.ops4j.org/pax/eclipse/update/
Maven Integration for Eclipse (m2eclipse)
Cytoscape build system has been moved to [http://maven.apache.org/ Maven]. To use maven from Eclipse, you need to follow [:MavenInfo:this] instruction. Even if you run all maven commands from Eclipse, you still need to install command-line version of Maven since Eclipse embedded version of maven have issues to execute some maven goals.
m2eclipse plugin update site - http://m2eclipse.sonatype.org/update/
Replace Maven Executable Used in Eclipse
Open Preferences window from Window menu
Specify your local installation of Maven. Note: this is not the bin directory, the root of Maven installation
- attachment:maven1.png
Set user settings.xml file location. This file can be copied from conf directory in the Maven root.
- Apply settings
Now your machine is ready for Cytoscape 3 development!
My Testing Environment
I've tested the following tutorial on these platforms:
- Common
- Eclipse 3.4 Ganymede (32 bit version)
- Apache Maven 2.0.9
- Subclipse Plugin 1.4.1
- m2eclipse Plugin 0.9.5.20080717-1821
- Pax Cursor Plugin 0.6.0
Test Platform 1 (Unix) Confirmed to work
- RHEL 4 Workstation
- Java SE 5 update 15
Test Platform 2 (Windows) Still have some issues
- Windows XP SP3
JDK SE 6 update 7 Important Note: You should use JDK, not JRE.
Test Platform 3 (Mac) Confirmed to work
- Mac OS X Tiger (10.4.11)
- Apple's Java SE 5 (1.5.0_13)
Checkout and Create Cytoscape 3 Eclipse Project
In this section, you will learn how to create an Eclipse project from the fresh Cytoscape 3 checkout.
Checkout Cytoscape 3 Trunk
- Start Eclipse. I recommend to use an empty, new workspace only for Cytoscape 3 project since it creates tons of new bundle projects in your workspace.
Select Window > Show View > Other > SVN > SVN Repository. SVN Repository viewer will be displayed.
- Add new SVN repository by pressing following icon:
- attachment:eclipse_plugins2.png
Core Developers: svn+ssh://grenache.ucsd.edu/common/svn
- Note: you need to set up SSH client if you are a Windows user.
Others: http://chianti.ucsd.edu/svn - You can checkout the project from this URL, but cannot checkin.
Once you specify the repository location, you can see the entire repository tree. The Cytoscape 3 repository is cytoscape3/trunk. attachment:eclipse_plugins3.png
From SVN Repository window, right-click cytoscape3 > trunk and select Check out as Maven project...
Select Source Code Management (SCM) system type to svn and make sure the URL is set to http://chianti.ucsd.edu/svn/cytoscape3/trunk (for core developers, svn+ssh://grenache.ucsd.edu/common/svn/cytoscape3/trunk).
Click Finish
- attachment:eclipse_core11.png
- Now your Eclipse workspace looks like the following:
- attachment:eclipse_core2.png
Build Project and Run Cytoscape 3 on Felix
First, let's build and run Cytoscape 3 from Eclipse.
Select core project on the workspace. Right click and select Run As > Maven install. This command builds and install Cytoscape 3 bundles to your local maven repository and it takes several minutes to complete (depends on your machine power).
- attachment:maven_install.png
- If you cannot complete this process due to failing tests, try the following:
Select Run > Run Configurations
Set core as the base directory
Set install for goal and check Skip Tests
Apply and Run
- attachment:maven_install2.png
This is a workaround for failing tests in Windows environment. We are working on this issue and once it is solved, you can call install goal from right-click menu.
- If you cannot complete this process due to failing tests, try the following:
- attachment:maven_install.png
Select Run → Run Configurations
Create new Maven Build and name it
Set the Base directory to core bundle
Set the goal to pax:provision
- attachment:eclipse_core20.png
- Apply and Run. You can use Felix Shell commands on the console.
- attachment:eclipse_core21.png
- Quit Cytoscape
Debug Cytoscape 3 on Eclipse with PAX Cursor
In this section, you will learn how to debug Cytoscape 3 on Eclipse.
First, let's set a sample break point in CytoscapeInit class, which is the class to startup Cytoscape. It is in application/src/main/java/cytoscape/CytoscapeInit.java. You can set breakpoint anywhere in the public boolean init(CyInitParams params) method.
- attachment:debug0.png attachment:pax0.png
From Eclipse main window, select Run → Debug Configurations
Right click on OSGi Framework and select New
Name the configuration Cytoscape 3
Switch framework to Felix 1.0.4
None of the files should be selected in the bundle list
- attachment:pax1.png
Click the Pax Cursor tab
Click Add Pom. Then select pom file under runner directory. To get the deploy-pom.xml file to show, you have to change the File of type ComboBox to have Any File.
- attachment:pax2.png
Apply and Debug
- attachment:pax3.png
- Now you can see Cytoscape running on Felix and debugger shows current status of variables
- attachment:pax4.png
Just like other applications, Eclipse debugger stops execution at the break-point you specified in the source code. To start again, you need to press green triangle (Resume button).
- attachment:pax5.png
Basically, the debugging process is same as regular Java projects. Once you edit something in the source code, you can rebuild and deploy it to local repository by Maven install command. Then you can repeat the procedure above to check internal states of Cytoscape 3 by Eclipse debugger.
Working with Felix OSGi Console
Cytoscape 3 is an OSGi application and you can check the status of bundles from OSGi console. After you start Cytoscape 3 from Eclipse, you can see a prompt on the Console window (if not, hit enter in the console to show the prompt). The following is some useful command to check internal states of the OSGi system. For more information, please visit [Felix web site].
help - display help message
-> help bundlelevel <level> <id> ... | <id> - set or get bundle start level. cd [<base-URL>] - change or display base URL. headers [<id> ...] - display bundle header properties. help - display impl commands. install <URL> [<URL> ...] - install bundle(s). packages [<id> ...] - list exported packages. ps [-l | -s | -u] - list installed bundles. refresh [<id> ...] - refresh packages. resolve [<id> ...] - attempt to resolve the specified bundles. services [-u] [-a] [<id> ...] - list registered or used services. shutdown - shutdown framework. start <id> [<id> <URL> ...] - start bundle(s). startlevel [<level>] - get or set framework start level. stop <id> [<id> ...] - stop bundle(s). uninstall <id> [<id> ...] - uninstall bundle(s). update <id> [<URL>] - update bundle. version - display version of framework.
ps - List loaded bundles
-> ps START LEVEL 4 ID State Level Name [ 0] [Starting ] [ 0] System Bundle (1.0.4) [ 1] [Active ] [ 4] cytoscape.util.intr [cytoscape] (1.0.0.SNAPSHOT) [ 2] [Active ] [ 4] cytoscape.graph.fixed [cytoscape] (1.0.0.SNAPSHOT) [ 3] [Active ] [ 4] cytoscape.graph.dynamic [cytoscape] (1.0.0.SNAPSHOT) [ 4] [Active ] [ 4] org.cytoscape.network [org.cytoscape] (1.0.0.SNAPSHOT) [ 5] [Active ] [ 4] cytoscape.render.immed [cytoscape] (1.0.0.SNAPSHOT) [ 6] [Active ] [ 4] cytoscape.geom.spacial [cytoscape] (1.0.0.SNAPSHOT) [ 7] [Active ] [ 4] cytoscape.render.stateful [cytoscape] (1.0.0.SNAPSHOT) [ 8] [Active ] [ 4] cytoscape.geom.rtree [cytoscape] (1.0.0.SNAPSHOT) [ 9] [Active ] [ 4] cytoscape.render.export [cytoscape] (1.0.0.SNAPSHOT) [ 10] [Active ] [ 4] org.cytoscape.attributes (1.0.0.SNAPSHOT) [ 11] [Active ] [ 4] org.cytoscape.tunable (1.0.0.SNAPSHOT) [ 12] [Active ] [ 4] cytoscape.task [cytoscape] (1.0.0.SNAPSHOT) [ 13] [Active ] [ 4] phoebe.dnd [phoebe] (1.0.0.SNAPSHOT) [ 14] [Active ] [ 4] undo (1.0.0.SNAPSHOT) [ 15] [Active ] [ 4] org.cytoscape.view (1.0.0.SNAPSHOT) [ 16] [Active ] [ 4] org.apache.commons.cli [org.apache] (1.0.0.SNAPSHOT) [ 17] [Active ] [ 4] Apache Commons Lang (2.4.0) [ 18] [Active ] [ 4] org.cytoscape.layout (1.0.0.SNAPSHOT) [ 19] [Active ] [ 4] org.cytoscape.vizmap (1.0.0.SNAPSHOT) [ 20] [Starting ] [ 4] cytoscape.application [cytoscape] (1.0.0.SNAPSHOT) [ 21] [Resolved ] [ 4] JDOM DOM Processor (1.0.0) [ 22] [Resolved ] [ 4] Java Activation API (1.1.0) [ 23] [Installed ] [ 4] Concurrent (1.3.4) [ 24] [Resolved ] [ 4] Lowagie iText (2.0.8) [ 25] [Installed ] [ 4] csplugins.automatic.layout [csplugins] (1.0.0.SNAPSHOT) . . .
services - show list of available OSGi Services
services BUNDLE_ID - show detail of services abailable from the bundle
-> services 25 csplugins.automatic.layout [csplugins] (25) provides: ----------------------------------------------------- name = force-directed objectClass = org.cytoscape.layout.CyLayoutAlgorithm preferredMenu = Cytoscape Layouts service.id = 21 ---- name = circular objectClass = org.cytoscape.layout.CyLayoutAlgorithm preferredMenu = Cytoscape Layouts service.id = 22 ---- name = hierarchical objectClass = org.cytoscape.layout.CyLayoutAlgorithm preferredMenu = Cytoscape Layouts service.id = 23 ---- . . .
services -u - show usage of services.
-> services -u System Bundle (0) uses: ----------------------- org.osgi.service.startlevel.StartLevel org.cytoscape.layout (18) uses: ------------------------------- org.cytoscape.layout.CyLayoutAlgorithm org.cytoscape.layout.CyLayoutAlgorithm org.cytoscape.layout.CyLayoutAlgorithm org.cytoscape.layout.CyLayoutAlgorithm org.cytoscape.layout.CyLayoutAlgorithm
services -u BUNDLE_ID - show more detail about service usage of the bundle
org.cytoscape.layout (18) uses: ------------------------------- name = force-directed objectClass = org.cytoscape.layout.CyLayoutAlgorithm preferredMenu = Cytoscape Layouts service.id = 21 ---- name = circular objectClass = org.cytoscape.layout.CyLayoutAlgorithm preferredMenu = Cytoscape Layouts service.id = 22 ---- name = hierarchical objectClass = org.cytoscape.layout.CyLayoutAlgorithm preferredMenu = Cytoscape Layouts service.id = 23 ---- . . .
Note: The behaviour of Cytoscpae 3 running on Felix will be different from time to time. This is because budle loading timing is not properly controlled now. This will be solved by organizing bundle/service dependency. I'm working on this issue now and hopefully it will be solved soon.
Additional Notes
Now you are ready to hack Cytoscape 3 on Eclipse. As you can see on your workspace, Cytoscape 3 is a collection of OSGi bundles. Each bundle is built as a Maven project and has a pom.xml file.
Currently, the desktop version of Cytoscape 3 is called application bundle. Under src/main/java you can see the source tree. You can edit these source files just like 2.x series, and create the bundle by running maven commands. To run them, you need to select (right click) the project name and then select maven command from Run As menu:
- attachment:eclipse_core6.png
- maven clean - clean all classes from target directory.
- maven install - build everything under the selected project, create bundles, run tests, and install them to your local Maven repository
To run your modified code, you just need to do maven install and run debugger.
Troubleshooting
Somehow Cytoscape 3 Eclipse project is broken and I cannot compile it anymore
From terminal, run mvn pax:clean pax:eclipse. This cleans up everything and gives you a fresh workspace.
pax:provision fails. What should I do?
Cleaning up the working space (maven clean) and rebuilding it (maven install) solves this problem in most cases.
Cannot compile application bundle. Eclipse display some warning messages and cannot complete install goal
Comment out following lines in pom.xml in core directory:
<showWarnings>true</showWarnings> <showDeprecation>true</showDeprecation>
This document is written by KeiichiroOno DateTime()
If you have any questions, please e-mail me (kono at ucsd dot edu)