Difference between revisions of "CompileProtege5InEclipseWithMaven"

From Protege Wiki
Jump to: navigation, search
(Configuring Eclipse)
(Configuring Eclipse)
Line 44: Line 44:
 
In this window configure the M2_REPO variable so that it points to the local maven repository which is usually (always?) located at '.m2/repository' in your home directory.  This allows me to set up the eclipse projects so that they do not require pointers to system specific locations.  The system specific location of the repository is set once in the eclipse workspace rather than several times in each project.
 
In this window configure the M2_REPO variable so that it points to the local maven repository which is usually (always?) located at '.m2/repository' in your home directory.  This allows me to set up the eclipse projects so that they do not require pointers to system specific locations.  The system specific location of the repository is set once in the eclipse workspace rather than several times in each project.
  
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:
+
Now we can import the eclipse projects from the protege5 directory. From the file menu click Import, select General/Existing Projects into Workspace, and click next:
  
 
[[File:MavenEclipseImportExisting1.png]]
 
[[File:MavenEclipseImportExisting1.png]]
Line 52: Line 52:
 
[[File:MavenEclipseImportExisting2.png]]
 
[[File: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:
+
A good initial selection of three projects to include are org.protege.common, org.protege.editor.core.application and org.protege.editor.owl.
 
 
[[File:MavenEclipseImportExisting3.png]]
 
  
 
== Running Protege ==
 
== Running Protege ==
  
 
== Add your own plugin ==
 
== Add your own plugin ==

Revision as of 09:55, August 10, 2013

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.

Now we can set up the projects for eclipse. To do this first download a zip file that contains the eclipse information. This zip file is held at the following location

         http://protege.stanford.edu/fileshare/tredmond/maven-eclipse-projects.zip

Unzip this file into the protege5 directory. Note that in addition to including the usual .project and .classpath files, this zip file also contains the META-INF/MANIFEST.MF files. These manifest files are duplicates of the manifest files that are included in the bundles that are created by the mvn build scripts.

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. To do this, click on Window->Preferences, select General->Workspace->Linked Resources and click on the button that defines a new path variable.

MavenEclipseSetREPO.png

In this window configure the M2_REPO variable so that it points to the local maven repository which is usually (always?) located at '.m2/repository' in your home directory. This allows me to set up the eclipse projects so that they do not require pointers to system specific locations. The system specific location of the repository is set once in the eclipse workspace rather than several times in each project.

Now we can import the eclipse projects from the protege5 directory. 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.

Running Protege

Add your own plugin