Comments? Feedback?

This wiki does not yet support public comments (a limitation of Google Sites), so we encourage you to post your comments on Twitter by responding to @orbeon.

Java Development and IDE Settings

Scope

This section is not about developing applications with Orbeon Forms, but about developing Orbeon Forms itself. It is for those who want to modify the code of Orbeon Forms. This documentation provided here is very much work in progress. If you would like to contribute to the Orbeon Forms development and don't find all the information you are looking for here, please feel free to join the ops-users mailing list and ask your question on the list. 

Java version

The server part of Orbeon Forms is developed in Java. As of July 2009, it requires Java 5 or newer. In particular, the code base uses the following features of Java 5 :
  • Generics
  • New for loops
  • Autoboxing
  • Enumerations
Orbeon Forms dependencies such as Saxon and eXist also will soon require Java 5.

Nightly builds

At any time you can download a nightly build, which is a build of the latest Orbeon Forms source code.

Unlike released versions of Orbeon Forms, nightly builds are not tested before they are made available. The only guarantee is that nightly builds pass the Orbeon Forms unit tests. A build that does not pass all the unit tests is not uploaded to the nightly build directory. The Orbeon Forms developers are doing their best not to cause any regression in nightly builds, so in most cases you can use nightly builds for development. If you notice any regression is a nightly build, please report it on ops-users.

The name "nightly builds" seems to imply that they are created only once a day. In fact, nightly builds are created at all time during the day, whenever a modification occurs on the code repository. So there might in fact be several nightly builds in a day of development is active during that day, or no new build if nothing was checked in the repository that day.

Getting the source

First note that if your main reason for getting the source is to have a build of Orbeon Forms with the latest code, we recommend that you instead download a nightly build (see above).

The source code of Orbeon Forms is available on the git repository.

Building with ant

We build Orbeon Forms with Ant. The Ant configuration file (build.xml) is located at the root of the source directory. You can start Ant from the command line. If you are using an IDE like Eclipse or IntelliJ, you can also use the builtin Ant support provided by your IDE. The Orbeon Forms build.xml defines a number of targets, but only a few are used frequently:
  • orbeon-war: Build Orbeon Forms and creates an exploded war file in the directory build/ops-war. To test your modifications to the Orbeon Forms code, you will typically run a Tomcat with a context pointing to that directory. That context, defined in Tomcat's server.xml will typically look like:

    <Context crossContext="true" debug="0" docBase="path to your source/build/ops-war" path="/ops" reloadable="false"/>

  • orbeon-dist-war: This will build a "distribution" war file, which is equivalent to the war file created by our automated build system and uploaded to the "unstable builds" directory. The produced file will be located in build/distrib/orbeon.war

Building with your IDE

NOTE: If you use the directory-based project settings (.idea directory), you can also check our configuration files directly from git.

During development, you can choose to compile Java files with your IDE instead of compiling them with Ant. You might want to do this because:
  • The compiler that comes in your IDE may be faster than plain javac
  • The compiler that comes in your IDE may report better errors
  • The compiler that comes in your IDE may better handle dependencies
  • You should be able to leverage HotSwap in the JVM.
  • The IDE's debugger might work better!
HotSwap works by starting the VM in debug mode and connecting to the VM with your IDE. As your application is running, you can then modify the Java code, and recompile it with your IDE. After the IDE has successfully compiled any modified Java file, it will send the new code to the JVM, which will replace the old code with the new code. HotSwap still has limitations: it is not a silver bullet and there will be cases where you will need to redeploy the web application or restart the application server. But you will spare yourself a redeployment or restart in most of the cases where your modification to the Java code does not significantly change the structure of the Java class. If you are using IntelliJ, you can find more information about HotSwap on their site.

To compile files from your IDE:
  • Ant setup:
    • Set the skip.compilation Ant property (you just need to have this property set some value; the value of the property does not matter).
    • If you have compiled code before without this property, run first the clean Ant task.
    •  With the skip.compilation property set, run the orbeon-war Ant task.
  • IDE setup:
    •  Set your IDE to generate class files in build/orbeon-war/WEB-INF/classes.
    •  Point your IDE to the jar files in the lib directory, as the Orbeon Forms code has dependencies on those libraries.
    •  Setup your IDE to compile the files in src/java.
  • Once this setup is done:
    •  Compile all the sources a first time before you start the application server.
    •  Start the application server in debug mode.
    •  Connect to the application server with your IDE.
    •  Now comes the interesting part: modify Java code whenever you want, compile it, and your IDE will send the new code to the JVM which will on the fly use this new code instead of the old one.
IntelliJ 8.1 ant property setup

IntelliJ 8.1 compiler paths setup

IntelliJ 8.1 source code setup


IntelliJ Setup

What follows are tips how how to better use and configure IntelliJ.

Resolving XInclude Paths

If you are using XInlcude in IntelliJ, you might have seen errors like this:


An XInclude errors reported by IntelliJ 8.1

IntelliJ attempts to resolve paths in XInclude relative to the paths you defined as source folders in your Project Structure. You might have defined paths like src/java as a source folder; that is: folders in which you have Java code. But if you keep you resources separate from your Java files (i.e. in src/resources and src/resource-packaged like we do in Orbeon Forms), you will get the error above as IntelliJ fails to find a file src/java/foo/bar.xhtml.

As of IntelliJ 8.1, you can't disable this behavior so rather than become numb to errors reported by IntelliJ, you can setup it up to look for those files in your resources folder by adding resources a Source Folder or Test Source Folder.


Adding resource paths as source folders in Project Structure (screenshot from IntelliJ 8.1)

A negative side-effect of this configuration is that when compiling your source with IntelliJ as described earlier, it will copy all the files that it considers to be resources in the output path. Mostly, this means that compiling will start taking more time than it should. You can disable this behavior by editing the pattern that describes what IntelliJ considers to be a resource. You can change this pattern under Settings, Compiler, Resource patterns. Entirely removing the pattern will do.


Removing the resource pattern under Settings, Compiler (screenshot from IntelliJ 8.1)

Performing VCS Operations in the Background 

It isn't clear why IntelliJ doesn't by default perform all the operations on your version control system (VCS) in the background, but you can enable this on per-projet basis in Settings, Version Control, Background, as shown in the following screenshot.

Enabling background VCS operations (screenshot from IntelliJ 8.1)

Testing with your IDE

IntelliJ supports a built-in JUnit front-end which can be convenient.

To configure it, go to Run -> Edit Configurations and create a new JUnit configuration called e.g. "Orbeon Forms Tests":

IntelliJ 8.1 test configuration

The classpath settings come from the Orbeon module, which uses as JAR directory the /Users/ebruchez/Documents/Orbeon/orbeon/lib directory.

Make sure you set the following VM parameters:

-Doxf.resources.factory=org.orbeon.oxf.resources.PriorityResourceManagerFactory
-Doxf.resources.priority.1=org.orbeon.oxf.resources.FilesystemResourceManagerFactory
-Doxf.resources.priority.1.oxf.resources.filesystem.sandbox-directory="$PROJECT_DIR$"/src/resources-packaged
-Doxf.resources.priority.2=org.orbeon.oxf.resources.FilesystemResourceManagerFactory
-Doxf.resources.priority.2.oxf.resources.filesystem.sandbox-directory="$PROJECT_DIR$"/src/resources
-Doxf.resources.priority.3=org.orbeon.oxf.resources.FilesystemResourceManagerFactory
-Doxf.resources.priority.3.oxf.resources.filesystem.sandbox-directory="$PROJECT_DIR$"/test/src
-Doxf.resources.priority.4=org.orbeon.oxf.resources.FilesystemResourceManagerFactory
-Doxf.resources.priority.4.oxf.resources.filesystem.sandbox-directory="$PROJECT_DIR$"/src/java
-Doxf.resources.priority.5=org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory
-Doxf.resources.common.min-reload-interval=50
-Doxf.test.config=oxf:/ops/unit-tests/tests.xml


When running the test, IntelliJ shows which tests pass and fail:

IntelliJ 8.1 test output