Setup for Automating Flex Builds with Maven

A few weeks ago, a colleague and friend of mine, made me a presentation on one of the maven features, that is generating archetypes. Maven archetypes are basically some project-prototypes, that help you generate a new personalized project. Instead of copying files and renaming packages by hand, maven does all that for you, and it even names the packages with the name you provide. Maven does many other things and later I discovered that with only some XML lines you can orchestrate a complex build.

This nice features got me curious to learn more about Maven.

In case you’re asking Why would I use Maven with Flex ? let me share my own reasons:

  1. Resolves project dependencies automatically so that it’s easy to keep the project up to date with latest versions. Once you declare the Maven dependencies, the build automatically downloads all the requires JARs, SWCs into a local repository and it uses them from there.
  2. A lot of stuff you normally write with Ant scripts is already there. As a result, for most of the projects you don’t need to write something particular.
  3. It’s easy to compile the project with a different Flex SDK. You just change the SDK version and you can start building immediately ( due to the previous point, if the SDK is not in the local repository it gets downloaded automatically)
  4. It’s easy to compile all the tests, just by specifying the testSourceDirectory, which contains all the test files you have created. You don’t need to provide an AllTests.as file, in which you insert manually each test file you need.
  5. Easy to distribute such a project ensuring that everybody compiles it with the same versions for dependencies
  6. Easy to compile a Flex project along with a BlazeDS/LCDS project, and package a complete WAR with the entire application. It’s also easy to switch between BlazeDS/LCDS on the fly, if you orchestrate your build properly.
  7. It’s easy to integrate with Eclipse, because of the m2eclipse plugin.

So, if these reasons matches with your project, then you could read bellow how to set up your computer to build Flex projects with Maven.

  1. Setup Maven
    • Check the System Requirements for Maven.Basically you need to have a JDK installed. I’m using 1.5 and 1.6.
    • Download Maven ( minimum required version is 2.0.9 )
    • Download the zip and save it locally
    • Install it by unzipping into a specific location
    • Follow the Installation Instructions detailed in the download page
    • If you skipped the optional step from the Installation Instructions, about setting MAVEN_OPTS, it’s time to set it up now because you need it. For example, my MAVEN_OPTS are -Xmx1024m -Xms128m
  2. Prepare maven to build a Flex project
    • Make sure you have a corresponding Adobe Flash Player — Debugger Version installed on the computer.
    • Add the Flash Player to your PATH
      • For Unix-based Operating Systems (Linux, Solaris and Mac OS X), you can do this:
        export PATH=$PATH:/Applications/Flash\ Player.app/Contents/MacOS/

        Notice that in the PATH variable I have escaped the space !

      • For Windows 2000/XP/VistaA sample location in addition to the PATH it could be
        c:\Flex 3 SDK\3.2.0\runtimes\player\10\win\


That’s it. You are now ready to run a maven build on your machine. I will post soon a basic  “Hello World” Flex Application so you can test your maven installation.


Basic “Hello-world” Application with Maven build is available for download now. Unzip the archive into a folder, navigate into that folder, into “client-app” folder. In there you have the pom.xml file , which is the maven build file. From the command line issue: mvn clean install. First build should take a while, because it downloads all the maven dependencies into the computer’s local repository, found in ~/.m2/repository.


Sorry, the comment form is closed at this time.

Comments RSS Feed