Creating a Continuous Integration enviroment for Flex with Hudson ( 3 )

Categories: flex
Written By: sebi

One of our projects reached the level of complexity by both the term of prebase and developer-hours that we decided to go for a test ride with a CI ( Continuous Integration ) server.

Prepare for Flex

We left our build server in a blank state, starting with the operating system. Now let’s go and prepare it for using with Flex. First we will need Ant.

hudson@sebesteny:~$ sudo apt-get install ant
hudson@sebesteny:~$ ant
Buildfile: build.xml does not exist!
Build failed
hudson@sebesteny:~$

That’s ok, Ant runs, but no build file.
Get the Flex SDK, you can grab the newest from the Adobe site, or upload from your Flex Builder’s directory.

hudson@sebesteny:~$ mkdir flex_sdks
hudson@sebesteny:~$ wget http://fpdownload.adobe.com/pub/flex/sdk/builds/flex3/flex_sdk_3.4.1.10084.zip
hudson@sebesteny:~$ mkdir flex_sdks
hudson@sebesteny:~$ mkdir flex_sdks/3.4
hudson@sebesteny:~$ unzip flex_sdk_3.4.1.10084.zip -d flex_sdks/3.4

Here I had to install unzip with sudo apt-get install unzip

You can use multiple sdks in different projects.

We can write a quick test to make sure everything is running as expected. First create a build file for Ant.

<?xml version="1.0" encoding="utf-8"?>
<project name="AntTest" basedir="." default="default">
        <property name="FLEX_HOME" value="/home/hudson/flex_sdks/3.4" />
        <taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar"/>
        <target name="default">
               <mxmlc file="AntTest.mxml"  />
        </target>
</project>

Save it as build.xml, and create a simple Flex file too:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
</mx:Application>

Now run Ant

hudson@sebesteny:~/test$ ant
Buildfile: build.xml
 
default:
    [mxmlc] Loading configuration file /home/hudson/flex_sdks/3.4/frameworks/flex-config.xml
    [mxmlc] /home/hudson/test/AntTest.swf (173782 bytes)
 
BUILD SUCCESSFUL
Total time: 8 seconds
hudson@sebesteny:~/test$ ls -l
total 184
-rw-r--r-- 1 hudson hudson    116 2009-10-01 22:34 AntTest.mxml
-rw-r--r-- 1 hudson hudson 173782 2009-10-01 22:45 AntTest.swf
-rw-r--r-- 1 hudson hudson    329 2009-10-01 22:32 build.xml
hudson@sebesteny:~/test$

If everything went well, you can see the final AntTest.swf file in the directory. Two important things here, one is that you have to define the mxmlc task by providing the resource for it, , and that you have to define the FLEX_HOME variable, this is required by the flexTasks itself.

Leave a Reply