SMILA/Documentation/HowTo/Howto build a SMILA-Distribution

From Eclipsepedia

Jump to: navigation, search

Contents

Build Requirements

The build process uses Eclipse's PDE Build tools to build all the bundles, run all unit tests and create an ZIP archive with a complete SMILA application that can be installed and run independently from any development environment. To run this build process, you should first install the following software.


  • Eclipse SDK 3.6.2 for your operating system: We recommend installing a second Eclipse instance independently from the one you are using as your IDE so that additional installed Eclipse plugins you use in your work do not interfere with the build process (this shouldn't happen, usually - but just to be safe). You can find the download on http://download.eclipse.org/eclipse/downloads/. This How-to was tested with Eclipse Classic SDK 3.6.2.
  • DeltaPack matching your Eclipse version: The DeltaPack contains some additional bundles needed in the build, mainly for creating the SMILA executable for different platforms. You'll find the download on http://download.eclipse.org/eclipse/downloads/. Install it by unpacking it into you Eclipse SDK installation. This How-to was tested with DeltaPack 3.6.2.
  • Sun Java Development Kit: You need a full JDK, version 6, to build SMILA, not just a JRE. You can get it at [1]
  • Apache Ant: The build process is executed by Ant, which you can download here: http://ant.apache.org/. At least version 1.7 is needed (and tested).
  • Additional Libraries for building which are not included in SMILA repository. The build scripts assume the following directory structure for these libraries. You can either create this structure in your working copy of the SMILA repository next to all the SMILA bundles, or somewhere else on your hard disk and configure the build process to find them there (see below).
lib/
   ant-contrib/
      ant-contrib-1.0b1.jar
   checkstyle/
      checkstyle-all-4.3.jar
   emma/
      emma.jar, emma_ant.jar
   pmd/
      asm-3.1.jar, jaxen-1.1.1.jar, pmd-4.1.jar


    • ant-contrib: This is required to run the build. You may download it from: ant-contrib.
    • Furthermore our build process optionally generates reports for checkstyle, emma (code coverage) and pmd (static code analysis) if these libraries are present. The build is configured to run without these libraries and will just not create the respective reports, but everything else will be OK. To generate these reports you may download these files from:
      • checkstyle (use Checkstyle 4.x. The current rules do not work with 5.0)

Configuring the Build

The folder SMILA.builder contains everything needed to build SMILA and/or run all tests locally. The default settings are set to build against Eclipse 3.5 and build a product for Win 32bit and Linux 32bit. But it is also possible to build other platforms.  

Whether you build from command line or from eclipse, in both cases the make.xml ant script is executed. Before execution certain properties need to be set to meet the local setup.


Setting the Target Build Platform

Independent of which way you are going to build, you must copy the file build.properties.template to build.properties and set the configs property in build.properties for your setup.


Windows 32bit
...
configs=win32,win32,x86 
# ... 
Windows 64bit
...
configs=win32,win32,x86_64 
# ... 
Linux 32bit
...
configs=linux,gtk,x86
# ... 
Linux 64bit
...
configs=linux, gtk, x86_64
# ... 
Solaris SPARC
...
configs=solaris, gtk, sparc
# ... 

If you want to provide several distributions e.g one for windows 32bit and one for linux 32bit (default build plan), you have to string together the config values.


Example:
configs=win32, win32, x86 & \
 linux, gtk, x86 

The application distribution archive files will be created in subdirectory Application of the specified build directory (see below). For each configs entry $os, $ws, $arch a ZIP file named SMILA-incubation-$os.$ws.$arch.zip will be created.


Setting Build Properties

These are the main properties that can be used to configure the build process executed by make.xml. If you run the build from within Eclipse you must add them to the Ant launch configuration (see Executing make.xml from within Eclipse below), for running from command line we have included templates that you can adapt to your local setup (see Executing make.xml from command line below).

Property Default Comment
buildDirectory <SMILA_HOME>/eclipse.build directory where build output will be created. This should be always a subdirectory of SMILA_HOME. The application distribution ZIP files will be created in subdirectory Application of this directory.
builder <SMILA_HOME>/SMILA.builder directory where make.xml is located
eclipse.home <ECLIPSE_HOME> the location of the eclipse instance used to build SMILA
lib.dir <SMILA_HOME>/lib location of the additional build libs (ant-contrib, etc.)
pdeBuildPluginVersion 3.6.2.R36x_20110203 for build with Eclipse 3.6.2
equinoxLauncherPluginVersion 1.1.1.R36x_v20101122_1400 for build with Eclipse 3.6.2
os win32 these merely control under which platform the test will run. It must be one of the target platforms you have build.
ws win32
arch x86
test.java.home <JAVA_HOME>  a java 1.6 SDK instance

Executing the make.xml

all dependency graph

The default target is all. This will by default build the application and run all unit tests. Note that this can take quite a while. To build the distribution archives only, use targets clean and final-application. The dependency graph will explain what will happen and shows the relevant targets you may call instead.


Executing make.xml from within eclipse

Steps:

  1. set up devolopment environment see: How to set up dev environment
  2. select the SMILA.builder bundle
  3. open External Tools Configuration dialog (in Toolbar or Run -> External Tools submenu)
  4. create a new "Ant build" configuration or choose your configuration if exists
  5. set the "Buildfile" field to ${workspace_loc:/SMILA.builder/make.xml}
  6. set the "Base directory" field to ${workspace_loc:/SMILA.builder}
  7. insert all properties from above into the arguments input field (and adapt these to your setup) but prepend each with -D so each is passed into ant as a property (note that buildDirectory should be a subdirectory of your SMILA workspace directory), e.g. when using Eclipse 3.5 to build:
    -DbuildDirectory=D:/workspace/SMILA/eclipse.build
     -Declipse.home=D:/eclipse362
    -Dbuilder=D:/workspace/SMILA/SMILA.builder
    -Declipse.running=true
    -Dos=win32 -Dws=win32 -Darch=x86
    -Dlib.dir=D:/workspace/SMILA/lib
  1. Apply, and run SMILA.builder with this external tool configuration

Note: To start another than the default target select the targets of your choice on the "Targets" tab.

Executing make.xml from command line

The make.bat (or .sh) is just a shell script to set the properties that are needed for the ant script. These files exist only as templates in SVN with .#~#~# appended to denote their template nature. Copy one of them matching your system, but the names make.bat and make.sh is already in the svn:ignore to prevent it from beeing committed accidentally, so it is recommended to use them.

Both scripts are very similar, they start with setting some environment variables which are then used to create the build configuration properties and eventually feed them into an ANT call. There are the variables you usually need to check and adapt:

Variable Comment
SMILA_HOME location of your SVN working copy. Can be derived automatically in .sh script, in the batch file, you must set it yourself.
ECLIPSE_HOME the location of the eclipse instance used to build SMILA
ARCH operating system and platform settings for running the tests. See description of os, ws and arch properties above.
JAVA_HOME location of the JDK to build and run tests in. Must match the ARCH setting.

Tip: In case your compile log complaints about a non-1.6 compatible JVM despite the correct setting, you must also add the JAVA_HOME location to the ECLIPSE_HOME/eclipse.ini like so:
-vm
<JAVA_HOME>\bin

ANT_HOME location of your ANT installation
BUILDLIB_DIR location of your build files. If you placed them in the SMILA_HOME you can leave this untouched and comment out the libDir setting in the next line.
buildOpts choose the line matching your Eclipse installation or adapt them if you have another version installed.

Usually you don't need to change anything after the line setting buildOpts.

To run a build with the default target (all), open a command prompt or shell in the SMILA.builder directory and just enter.

make

To execute another than the default target just pass it (or them) as an argument:

make build

For example, to build the application distribution ZIPs without running the tests (which can take quite long), you can use:

make clean final-application

In Windows you will not see much output in the command prompt window, because the batch file redirects it to a logfile (named log.make, if the batch file is make.bat) so that you can check for error details after the build. You can install the GnuWin32 or Cygwin tools and use tee to have the output written to both console and logfile. The template contains the changed ANT call as a comment quite at the end of the script.