CompileProtege5InEclipseWithMaven

From Protege Wiki
Revision as of 09:02, August 10, 2013 by Tredmond (talk | contribs) (Configuring Eclipse)

Jump to: navigation, search

Instructions for setting up Eclipse for working with Protege using maven

Under construction

Prerequisites

To follow these directions you will need the following tools:

  • Eclipse (of course) with
    • the Plugin Development tools included. As indicated here, the plugin development environment comes with the Java EE or the RCP/Plugin versions of eclipse.
    • the Eclipse Subversive plugin, though this is only required if you want to do svn updates using eclipse. Note that there is another similar but different plugin (from Tigris I believe). I don't know if these plugins interfere with one another if they are both loaded.
  • A tool for checking out a repository from subversion (e.g. tortoise or the svn command line client).
  • Optionally a tool for checking out a git repository. This is useful for getting the owlapi sources and setting up owlapi projects.
  • Optionally the bnd tool. This is useful for creating owlapi bundles from the owlapi sources.
  • The maven build tool.

These directions are based on a preconfigured workspace which you can use for the build.


Configuring Eclipse

This is just one method of setting up eclipse and so feel free to adjust the approach to suit your preferences. When I first set up eclipse this way, I decided to have the Protege source tree be in a separate but parallel directory to the eclipse workspace. I decided that I like this arrangement because, as you will see, it ensures that the eclipse workspace files don't show up as modifications to the Protege source tree sources.

The first step in this process is to check-out the Protege sources. This can be done by checking out the svn tree (https://smi-protege.stanford.edu/repos/protege/protege4/misc/composite/protege5/trunk protege5). You can use any client that you like to perform the ckeck-out but for my command line client the command is as follows:

            svn checkout https://smi-protege.stanford.edu/repos/protege/protege4/misc/composite/protege5/trunk protege5

Now we build Protege using the maven command:

    cd protege5
    mvn clean install

This takes a little while to run (between two and three minutes on my computer) so now would be a good time to go get a cup of coffee. By running this, we have built a fully functional copy of Protege (in a directory with a name like protege-distribution/target/protege-distribution-5.0.0-beta-04-bin/Protege) and we have arranged that any generated source directories needed by the build are present. Talk about

Now we start eclipse to create a workspace. This step can actually be done while the maven install step abbove is running. In my example, I created the workspace in a separate directory, protege5-workspace that is at the same level as the protege5 directory that I just created. In this first run of eclipse, all that I plan to do is to setup a parameter that points to the local maven repository.


Now we are ready to start eclipse. I start eclipse and I make the new workspace be a directory parallel to the protege5 directory that I have been working on and I call it protege5-eclipse. Once eclipse has started, change to the Plug-in Development perspective. From the file menu click Import, select General/Existing Projects into Workspace, and click next:

MavenEclipseImportExisting1.png

In the next screen, make sure that "Select root directory" is selected, browse to the protege5 directory that we were working on before, select the plugins that you want to include and click finish:

MavenEclipseImportExisting2.png

A good initial selection of three projects to include are org.protege.common, org.protege.editor.core.application and org.protege.editor.owl. Now you need to tell eclipse where your local repository is located (I am not sure why it just doesn't know...). Go to the eclipse preferences, select Java->Build Path->Classpath Variables and add a new class path variable M2_REPO which points to the .m2/repository directory under your home directory:

MavenEclipseImportExisting3.png

Running Protege

Add your own plugin