|Fiji Is Just ImageJ|
|Featured Fiji Projects|
There are three different compilers we try to support:
- OpenJDK6 Javac
- Oracle Java SE 6 Javac
- Eclipse JDT Core
We do our best to ensure that all code in Fiji can be compiled with any of these three options. For more details, see the sections below.
MiniMaven: the Fiji Build System
The primary way to build Fiji, in whole or in part, is the Fiji Build System (a.k.a. MiniMaven). It is a custom build system for Fiji that uses the OpenJDK6 Javac compiler, using Maven's
Reasons why we created MiniMaven, instead of simply requiring Maven:
- Performance. When Maven first runs, it downloads many dependencies which are not strictly necessary for building the Fiji codebase. MiniMaven is minimalistic and hence more time- and bandwidth efficient than Maven is.
- Convenience. Fiji's
Build.shscript bootstraps everything, so there is no need to install another external tool beyond your Java Runtime Environment, or learn how to use the Maven command line tool (though if you already know Maven, you can use it; see below).
- Correctness. To avoid various Javac bugs, MiniMaven uses a customized version of javac, which is described in the commit history. Suffice to say that much blood, sweat and tears have been shed to ensure that MiniMaven can successfully build all the components of Fiji.
To build Fiji as a whole using MiniMaven, simply invoke the
Build.sh script at the top level.
To build a particular component of Fiji using MiniMaven, invoke the
Build.sh script on the target JAR you wish to build.
E.g., to build VIB-lib (assuming the JAR already exists):
$ ./Build.sh jars/VIB-lib*.jar
To force a clean rebuild, use the
-rebuild suffix with no space:
$ ./Build.sh jars/VIB-lib-2.0.0-SNAPSHOT.jar-rebuild
Alternately, you can build the code using Maven; see below for details.
All of Fiji is structured as Maven projects, meaning you can use Maven's standard
mvn command line tool to build all or part of the system.
When building with Maven on the command line, it will use your default installed JDK (unless you tell it otherwise). For example:
$ mvn --version Apache Maven 2.2.1 (rdebian-6) Java version: 1.6.0_26 Java home: /usr/lib/jvm/java-6-sun-22.214.171.124/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux" version: "3.0.0-17-server" arch: "amd64" Family: "unix"
$ java -version java version "1.6.0_26" Java(TM) SE Runtime Environment (build 1.6.0_26-b03) Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
On many systems, such as in the case above, the default installed JDK is Oracle's Java SE 6 platform. As such, we try to ensure that Fiji builds completely using Oracle's release of Javac, since it is so common.
To build a Maven-based component of Fiji from the command line, simply run
mvn from that component's toplevel directory.
E.g., to build VIB-lib:
$ cd src-plugins/VIB-lib $ mvn
Or to force a complete rebuild:
$ mvn clean install
Maven automatically runs any unit tests associated with the project upon build; to suppress this behavior, and thus improve build times, use:
$ mvn -DskipTests
The Eclipse JDT compiler
Eclipse is a powerful IDE for developing code. One advantage of the Maven project structure mentioned above is automatic support for development within Eclipse via the m2e plugin. See the Using Maven with Eclipse page for instructions in developing a Maven-based project (such as ImgLib2) within Eclipse.
It is important to understand that Eclipse uses a completely different compiler than Javac, part of Eclipse's JDT Core component. This incremental compiler is fast and powerful, and allows the Eclipse IDE to work its magic, but it has idiosyncrasies and bugs distinct from Javac (both OpenJDK6 and Oracle Java SE 6).
The main take-home message regarding Eclipse is: just because it compiles in Eclipse, does not mean it will compile with Javac (and vice versa, though the Eclipse compiler tends to be more lenient than Javac is).
Jenkins continuous integration system
To detect build failures more reliably, we have a Jenkins server (installed on an Ubuntu Linux 64-bit server) that automatically builds various projects in different ways. These automated builds help to detect problems with both the OpenJDK6 compiler as well as the Oracle Java SE 6 one.
Jobs that use MiniMaven
The following jobs use MiniMaven, and will test compilation with OpenJDK6:
- Fiji-minimal - Verifies that Fiji builds successfully with *no* submodules initialized. Runs automatically after each push to Fiji's remote Git repository.
- Fiji-daily - Verifies that Fiji builds successfully with *all* submodules initialized, once a day.
Jobs that use command-line Maven
The following jobs use command-line Maven, and will test compilation with Oracle Java SE 6:
- Fiji - Verifies that Fiji builds successfully. Runs automatically after each push to Fiji's remote Git repository.
- ImgLib2 - Verifies that ImgLib2 builds successfully. Runs automatically after each push to ImgLib2's remote Git repository.
- ImageJ - Verifies that ImageJ2 builds successfully. Runs automatically after each push to ImageJ's remote Git repository.
Fixing build problems
If you receive an email from Jenkins about a build failure, please take a look at the console output. If it looks related to code that you changed, try to find a fix or workaround so that all the different build mechanisms can continue to function. Broadly, the steps are as follows:
- Use the commands given above to replicate the problem on your system.
- Experiment with code changes to make the problem go away.
- Push your changes, with an explanation of what you did and why needed to do it. In many cases it is wise to provide a comment in the code (here is an example) to educate others on the issue, so that no one inadvertently removes your fix.
- After sufficient time elapses, verify that the Jenkins build is working again.
If you need help, please write to fiji-devel for assistance!