PluginAnatomy
From Protege Wiki
In Progress!
Contents
Introduction
The purpose of this web page is to describe some of the key ingredients of a plugin. The page will be directed by the quick development of a plugin and can indeed be used as a quick start guide. However, we will assume that the reader has an understanding of Java development and knows how to follow along in his favorite IDE. For more information about how to work with protege 4 in an IDE I will direct the reader to this page.
The vacuous plugin in one minute
Before we can start, we must set the PROTEGE_HOME environment variable to point to a Protege 4 distribution. This page has directions on how to do this in different operating systems but for now I will assume that we are on a unix (or os x) system. In that case, the system variable can be set with a simple commandexport PROTEGE_HOME=/Users/tredmond/Desktop/Protege_4.0_betaThe simplest (trivial) plugin can be built from sources in the following layout:
build.xml META-INF MANIFEST.MF lib resources srcAs we will see - even without any java sources - this is a sufficient basis for building a plugin that is recognized by Protege 4. There are only two files in this source tree - the build.xml file and the MANIFEST.MF. These files can be quickly put together from templates.
Build.xml
The template for the build.xml file can be downloaded from here. Only two things need to be changed in this build file. They can be found by searching for the string "CHANGE ME" in the file. The first thing to change is the name of the project. I will call the project the plugin tutoiral project:<project name = "plugin tutorial" default = "install" basedir = ".">The next setting that must almost always be changed is the name of the plugin. In this case, the build.xml already has the right name for the plugin but this is the only plugin for which this will be true:
<property name = "plugin" value = "org.protege.owl.examples.tab"/>
With these adjustments the build.xml file is ready.
MANIFEST.MF
The template for the MANIFEST.MF file can be downloaded from here. Only four things need to be changed in this file to make it useable. These can be found by searching for the string "CHANGE ME" in the file. The first change is to set the symbolic name. The usual default is to uses the same name as the plugin name in the build.xml file:Bundle-SymbolicName: org.protege.editor.owl.example.tab;singleton:=trueNote the "singleton:=true" line - this is important since most Protege 4 plugins will only work if they are instantiated exactly once. The next things to change are the bundle description, the vendor and the documentation url:
Bundle-Description: A simple plugin for a plugin development tutorial Bundle-Vendor: The Protege Development Team Bundle-DocURL: www.perhaps.i.donthaveoneyet.com
Actually the vendor and the docurl are optional and can be deleted. The MANIFEST.MF file is now ready.