Openfire: Building the Source

# Building the Source

This document provides detailed information for developers that wish to compile and make changes to the Openfire source code.

For additional developer resources, please visit: http://www.igniterealtime.org. The Openfire build process is based on Ant. Visit the Ant website for more information. There is no need to download and install Ant - a version of it is included in this distribution.

This documentation is divided into three sections:

1. Source -- get te Openfire source code.
2. Setup -- how to setup your environment for Openfire development.
3. Build tasks -- tasks that can be performed using the build program.

1. Get the Openfire Source

You can get the Openfire source code by downloading a source distribution or by checking out the source code from CVS. Instructions for both options can be found on the source page.

2. Setup Your Environment

Getting your machine ready for development requires a few steps. Wherever possible, instructions are provided for both Unix/Linux and Windows users.

Configure Java for Openfire

Java 5 (JDK 1.5) must be installed and setup on your machine. To test the installation, open a shell in a Unix or a MS-DOS prompt in Windows. Check your version of Java with "java -version" -- it must version 1.5 or greater. If Java isn't installed, download a copy from the Java website.

Important! -- the Openfire build tool needs to know where Java is installed on your system. You must configure the "JAVA_HOME" environment variable to point to the correct directory. Instructions on how to set this variable for various platforms are as follows:

- Unix/Linux
  1. Edit the ".profile" file in your home directory (or corresponding file for your shell).
  2. Set the JAVA_HOME environment variable by adding the following line to the file:

     export JAVA_HOME=/usr/local/jdk1.5

     The value "/usr/local/jdk1.5" should be replaced with your actual Java directory. Be sure there are no spaces after the end of the directory name. Do not add an extra slash after the directory name.

  3. Save changes to the file and then "source" it:

     source .profile

     The JAVA_HOME variable should now be configured correctly.

- WindowsNT/2000/XP
  1. Navigate to your desktop and right click on "My Computer"; choose properties.
  2. Select the "Advanced" tab and click on the "Environment Variables" button.
  3. Click the "New..." button in the System variables section. Enter the variable name "JAVA_HOME" and set the variable value to the full path of your Java installation. For example, "c:\jdk1.5". Be sure to not add an extra slash to the end of the directory name.
  4. Click "OK" in all of the menus to accept the changes.
  5. Close any open command prompt windows. The next time you open a command prompt, the "JAVA_HOME" variable will be set correctly.

- Windows95/98
  1. Open your autoexec.bat file (often at "c:\autoexec.bat") using Notepad.
  2. Add a line to the end of the file that resembles the following:

     set JAVA_HOME=c:\jdk1.5

     The value "c:\jdk1.5" should be replaced with your actual Java directory. Be sure there are no spaces between the "=" sign or after the end of the directory name. Do not add an extra slash after the directory name.

  3. Save changes to autoexec.bat and restart your computer.

Install the Ant Build Tool

The Openfire build process uses Ant, so that tool must be installed and configured on your computer. First download Ant from: http://ant.apache.org. Next, follow the installation instructions.

Test the Build Script

Navigate into the subdirectory of this distribution named "build" via the command-line.

Linux/Unix users only:You must make the ant script executable. From the build directory, type: `chmod u+x ant`

Now, invoke the build tool to compile the Openfire source code

Windows: ant
Unix/Linux: ./ant

If the build tool is invoked correctly and Openfire compiles, you've correctly configured your copy of the Openfire source distribution.

Finished!

If you've gotten this far, you've finished setting up the Openfire source distribution. Now, read below to learn about some of the tasks that you can perform with the build tool.

3. Build Tasks

The list of common build tasks is below. All build commands should be run from the "build" directory of your Openfire distribution.
For a full list of the commands and a brief description from the command line, type `ant -projecthelp`. For more complete help on several commands, read the documentation below.
To execute a build task, type `ant [options] targetname` where "targetname" is one of the targets listed below:

- Default
- openfire
- plugins
- clean

Each task is documented with a syntax guide and description. Optional paramaters for each task are enclosed with braces. If you would like to permanently set the value of a property, add it to build/build.xml file.

Default

Syntax:

ant

Description:

Equivalent of calling "ant openfire".

[return to task list]

openfire

Syntax:

ant openfire

Description:

Builds Openfire into the `target/openfire` directory. You can then launch Openfire using the scripts in `target/openfire/bin`.

[return to task list]

plugins

Syntax:

ant plugins

Description:

Builds all plugins into the `target/openfire/plugins` directory.

[return to task list]

clean

Syntax:

ant clean

Description:

Cleans all artifacts of the build process.

[return to task list]