# 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 Apache Maven. Visit the Maven website for more information.

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 Phases -- 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 8 (JDK 1.8) 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.8 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.8

     The value "/usr/local/jdk1.8" 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.8". 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.8

     The value "c:\jdk1.8" 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 Maven Build Tool

The Openfire build process uses Maven, so that tool must be installed and configured on your computer. First download Maven from: https://maven.apache.org. Next, follow the usage instructions.

Test the Build

Navigate into the root direcotry of this distribution named via the command-line.

Now, invoke the build tool to compile the Openfire source code: mvn compile 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.

3. Build Phases

Openfire conforms to the standard Maven build process. For a full list of the commands please review the Apache Maven documentation. For more complete help on several commands, read the documentation below.
To execute a build pahse, type `mvn "phase"` where "phase" is one of the keywords listed below:

- clean
- compile
- test
- package

Note that you can combine several phases, for example: `mvn clean package`. When a phase is given, Maven will execute every phase in the sequence up to and including the one defined. For example, when the 'package' phase is executed, the 'compile' and 'test' phases are also executed (but the 'clean' phase is not, unless specified explicitly). Please refer to the Maven documentation for more details.

clean

Syntax:

mvn clean

Description:

Cleans all artifacts of the build process.

[return to task list]

compile

Syntax:

mvn compile

Description:

Builds Openfire components (including plugins) into the `target` directory of each module.

[return to task list]

test

Syntax:

mvn test

Description:

Builds Openfire components, and runs all unit tests.

[return to task list]

package

Syntax:

mvn package

Description:

Builds Openfire components, runs all unit tests, and creates a distributable package in the `distribution` module. You can then launch Openfire using the scripts in `distribution/target/distribution-base/bin`.

[return to task list]