-
Notifications
You must be signed in to change notification settings - Fork 232
Setup in Eclipse
This page describes how to setup Protege in Eclipse for development. In this setup, Protege sources can be edited in Eclipse but the project is still compiled (outside of Eclipse) using maven. This configuration is most useful for developers who need to perform a few minor changes in the code. If you need to frequently modify the Protege sources, you can use an advanced setup, which offers a tighter integration with Eclipse. If you are interested in developing a plugin, please visit the Develop a Plugin page.
- Eclipse - version 4.5 (Mars) or above. To get the Maven and git integration out-of-the-box, it is strongly recommended to download the packaged Eclipse for Java EE Developers (Download Eclipse Mars Java EE).
- [git] (https://git-scm.com/)
- [Maven] (https://maven.apache.org/) version 3.1.0 or above.
- Java version 1.8 or above -- required starting with Protege 5.0 beta 18.
This guide will assume that you will get the source code in a directory called protege
.
- Clone Protege source code from GitHub. Type in a console:
git clone https://github.com/protegeproject/protege.git
- Change to the protege directory. Type in the console:
cd protege
- Build Protege. Type in a console:
mvn clean package
After the build completes, a Protege Desktop distribution will be available in the following directory:
protege/protege-distribution/target/protege-${version}-platform-independent-bin/Protege-${version}
. As an example, you may find the distribution packages are at
protege-distribution/target/protege-5.1.1-SNAPSHOT-platform-independent/Protege-5.1.1-SNAPSHOT
In the end, you will get a structure for the protege folder, similar to this:
protege
+ protege-common
+ protege-desktop
+ protege-editor-core
+ protege-editor-owl
+ protege-launcher
license.txt
pom.xml
README.md
-
Start Eclipse, optionally create a new workspace (e.g., File menu -> Switch workspace -> select a new folder name for the new workspace)
-
Import the pom files: File menu -> Import -> select Maven -> Existing Maven projects
In the dialog, select as root folder the protege folder that you just cloned before. Eclipse will find the master pom, as well as all the pom files from the subfolders. It will look like this:
- Click on Finish, and Eclipse will create individual projects for each subfolder, it will link them to Maven and Github. After this step, the projects in Eclipse will look like this:
- Update Maven projects: Right-click on any project -> Maven -> Update Project ... -> select all projects, click OK. This step should fix any errors that you might have gotten after the import. Remember to update projects, each time you do a change in the pom file.
- Create a new launch configuration: At the menubar select "Run -> Run Configurations ...". The selection will open a dialog window called "Run Configurations".
Look at the left tree panel and select "Java Application" and continue clicking at the upper left corner, the "New launcher configuration" icon. The right panel will immediately show you a new configuration form. Put a name for this new configuration, e.g., "Launch Protege 5.0".
Screenshot:
- Configure the launcher by filling in each tab as showed below:
2a) Main tab.
Fill in the fields as scripted below:
- Project:
protege-launcher
- Main class:
org.protege.osgi.framework.Launcher
- Add a check mark for the two options for including system libraries and inherited mains when searching the main class.
Screenshot:
2b) Arguments tab.
Fill in the fields as scripted below:
- VM arguments
-Dlogback.configurationFile=${workspace_loc}/protege/protege-desktop/target/protege-5.1.1-SNAPSHOT-platform-independent/protege-5.1.1-SNAPSHOT/conf/logback.xml
-DentityExpansionLimit=100000000
-Dfile.encoding=UTF-8
- Working directory > Other:
${workspace_loc}/protege/protege-desktop/target/protege-5.1.1-SNAPSHOT-platform-independent/protege-5.1.1-SNAPSHOT
NOTE: Make sure you replace the protege-5.1.1-SNAPSHOT
label according to the version you are working on.
Screenshot:
2c) Classpath tab
Add the executable JARs for Protege to run:
- Click on the "User Entries" label and then select "Add JARs..."
- Pick "protege-desktop" and run down the tree following the path
target/protege-5.1.1-SNAPSHOT-platform-independent/protege-5.1.1-SNAPSHOT/bin
- Select both
org.apache.felix.main.jar
andprotege-launcher.jar
- Click "OK"
Screenshot:
- Select "Apply" at the bottom right corner and continue select "Run".
If Protege opens then congratulation you are now able to run Protege from Eclipse. If you want to run in the debug mode then use the "Debug" icon in Eclipse by applying the same configuration.
This way of running and debugging Protege in Eclipse will likely not work with hotspot replace. If you make a change in the code, you would have to run a maven clean package
, then refresh the projects in Eclipse, so that the changes take effect. The positive side of this launcher configuration is that it corresponds exactly to how Protege would run from the distribution.