From Protege Wiki

Revision as of 05:10, July 5, 2009 by Tredmond (Talk | contribs)

Jump to: navigation, search

Using and Configuring Protege Ant Build Scripts

There is a standard format for the protege ant build scripts. The main idea behind these build scripts is that most of the dependencies needed by a plugin project can be found inside a protege distribution. Therefore the build file uses the PROTEGE_HOME environment variable to point to a Protege distribution and find the dependencies from there. This removes the problems where users commit jar files from the protege distribution and have to keep updating them.

So the simplest way of configuring the invocation of an ant build script is to set the PROTEGE_HOME environment variable. The way that this is done is system dependent:

  • On unix systems from the command line use "export PROTEGE_HOME=/home/tredmond/Desktop/Protege". This command can also be put in a .bashrc file. On the command line, unix systems also allow one to set a property for the duration of one command as follows
                    PROTEGE_HOME= /home/tredmond/Desktop/Protege" ant install
  • OS x machines are unix machines so all the unix techniques apply. However, in addition to this there is the

    file which contains a set of properties. The advantage of using this file is that it is invoked before applications that are invoked with a double click. There is a nice page about this here. So it might make sense to put environment property values in here that are seen by an IDE which is started with a double click.
  • On windows systems, right click on MyComputer and select settings. Then find Environment Variables and click then locate PROTEGE_HOME, press edit and change to the path to protege.
  • In eclipse follows these directions and then go to the environment settings page and add the environment setting.

In addition to the above, any variable in a Protege ant script can be configured by setting the value in a file. This is useful for an installation into a non-Protege application such as a tomcat web server.

Finally, for developers making install scripts, the ant target allows the developer to set variables in the called ant script as parameters. So for instance the place to install protege can be set in the ant script as follows:

        <ant antfile="...">
            <property name="protege.home" location="./build/Protege_4.0_NCI"/>

This is a very flexible technique and can be used to override any variables in the called ant script. This type of technique is being used at NCI to create custom builds of the NCI Protege in a controlled and consistent fashion.

How the Protege ant scripts work

The philosophy of the Protege build scripts is to use the PROTEGE_HOME environment variable as a pointer to the Protege installation directory and as a repository of the latest jars. We will show how this works by demonstrating how to quickly build a Protege 3 installation containing a few basic plugins. I have chosen Protege 3 rather than Protege 4 in this case because the main Protege 4.0 build file does not follow the paradigm that I am about to describe. However in Protege 4.1 this approach is already in use and several of the co-ode Protege 4 plugins use this approach also.

We will start by creating an empty directory and installing the core Protege 3 implementation into that directory. Please note that this build script was run on a very slow machine and will run much faster on modern platforms.

[tredmond@Andromeda protege-core]$ mkdir /tmp/Protege3
[tredmond@Andromeda protege-core]$ export PROTEGE_HOME=/tmp/Protege3
[tredmond@Andromeda protege-core]$ svn info
Path: .
URL: http://smi-protege/repos/protege/protege-core/trunk
Repository Root: http://smi-protege/repos/protege
Repository UUID: 30a32298-b1ee-0310-87e3-a7336bc3aa68
Revision: 14650
Node Kind: directory
Schedule: normal
Last Changed Author: tredmond
Last Changed Rev: 14624
Last Changed Date: 2009-06-27 11:29:11 -0700 (Sat, 27 Jun 2009)

[tredmond@Andromeda protege-core]$ ant clean
Buildfile: build.xml



Total time: 1 second
[tredmond@Andromeda protege-core]$ ant install
Buildfile: build.xml


    [mkdir] Created dir: /Andromeda/Users/tredmond/dev/workspaces/protege3/protege-core/classes
    [mkdir] Created dir: /Andromeda/Users/tredmond/dev/workspaces/protege3/protege-core/classes.junit
    [mkdir] Created dir: /Andromeda/Users/tredmond/dev/workspaces/protege3/protege-core/dist
    [mkdir] Created dir: /Andromeda/Users/tredmond/dev/workspaces/protege3/protege-core/docs/apidocs




   [javacc] Java Compiler Compiler Version 4.0 (Parser Generator)
   [javacc] (type "javacc" with no arguments for help)
   [javacc] Reading from file /Andromeda/Users/tredmond/dev/workspaces/protege3/protege-core/bin/Parser.jj . . .
   [javacc] Warning: Line 4, Column 5: Bad option name "OPTIMIZE_TOKEN_MANAGER".  Option setting will be ignored.
   [javacc] Note: UNICODE_INPUT option is specified. Please make sure you create the parser/lexer using a Reader with the correct character encoding.
   [javacc] File "" does not exist.  Will create one.
   [javacc] File "" does not exist.  Will create one.
   [javacc] File "" does not exist.  Will create one.
   [javacc] File "" does not exist.  Will create one.
   [javacc] Parser generated with 0 errors and 1 warnings.

    [javac] Compiling 891 source files to /Andromeda/Users/tredmond/dev/workspaces/protege3/protege-core/classes
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
     [rmic] RMI Compiling 1 class to /Andromeda/Users/tredmond/dev/workspaces/protege3/protege-core/classes
     [rmic] RMI Compiling 1 class to /Andromeda/Users/tredmond/dev/workspaces/protege3/protege-core/classes
     [rmic] RMI Compiling 1 class to /Andromeda/Users/tredmond/dev/workspaces/protege3/protege-core/classes
     [rmic] RMI Compiling 1 class to /Andromeda/Users/tredmond/dev/workspaces/protege3/protege-core/classes
     [copy] Copying 186 files to /Andromeda/Users/tredmond/dev/workspaces/protege3/protege-core/classes
     [copy] Copied 4 empty directories to 1 empty directory under /Andromeda/Users/tredmond/dev/workspaces/protege3/protege-core/classes

     [copy] Copying 1 file to /Andromeda/Users/tredmond/dev/workspaces/protege3/protege-core/dist
      [jar] Building jar: /Andromeda/Users/tredmond/dev/workspaces/protege3/protege-core/dist/protege.jar

     [copy] Copying 1 file to /tmp/Protege3
     [copy] Copying 1 file to /tmp/Protege3
     [copy] Copying 1 file to /tmp/Protege3
     [copy] Copying 9 files to /tmp/Protege3
     [copy] Copying 12 files to /tmp/Protege3/examples
    [mkdir] Created dir: /tmp/Protege3/plugins
    [mkdir] Created dir: /tmp/Protege3/logs

Total time: 40 seconds
[tredmond@Andromeda protege-core]$ 

At this point you can go to the Protege 3 installation and run it and it will be able to load frames projects. This is the most basic Protege 3 installation. The PROTEGE_HOME environment variable has only been used to determine the location to install Protege.

Personal tools