Maven & Flex-mojos

To build and deploy Flex application I usually use Apache Ant with Flex Ant Tasks which come with the Flex SDK.

A few month ago the Flex-mojos blog got my attention and I added it to my RSS Reader and now I finally got the time to play around with it.

“Flex-mojos is a collection of maven plugins to allow maven to compile, optimize, test and … Flex SWF, Flex SWC, Air SWF and Air SWC. The main goal is to provide a full support to all mxmlc/compc options.”

“Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information.”

This all sounds pretty promising so I gave it a try. I am under OS X so the commands are slightly different under Windows.

Install Maven

export M2_HOME=/path/to/maven
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
mvn --version

If you see the Maven and Java version info you know your installation was successful.

Flex Mojos with Flex SDK 3.1.0

The first thing I tried was to follow the Flex-mojos HelloWorld tutorial. I got the same 4 missing artifacts error like you see below in the comments. After some research on Velos blog and the goal to compile with 3.1.0 the research began ;) .

The first thing is to copy the Maven settings.xml from /path/to/maven/conf/settings.xml to ~/.m2 which is your Maven user directory.

HINT: You can open this hidden directory in Finder from the Terminal with open ~/.m2.

Integrate the settings by Velo like described here and provided here.

Update to 2.0M5 (and change the path to your sdk):

mvn info.flex-mojos:install-mojo:2.0M5:install-sdk -Dflex.sdk.folder=/Users/soenkerohde/sdks/3.1.0/ -Dversion=

Due to a typo bug in the 2.0M5 super-pom we will work without super pom so you have to comment the parent node add add the contents from the super-pom which should look like this pom.xml.

Now things should be ready to go:

mvn install
INFO] Installing /Users/soenkerohde/maven/myproject/target/simple-flex-application-1.0-SNAPSHOT.swf to /Users/soenkerohde/.m2/repository/com/example/flex/simple-flex-application/1.0-SNAPSHOT/simple-flex-application-1.0-SNAPSHOT.swf
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12 seconds
[INFO] Finished at: Mon Sep 29 16:01:16 CEST 2008
[INFO] Final Memory: 9M/55M
[INFO] ------------------------------------------------------------------------
soenkerohde:myproject soenkerohde$

Yeah! So this was “HelloWorld” and my first impression of Maven after walking into every trap is pretty good. I will try to blog more when I get more experience.

I also read a few things about Maven archetypes which is the Maven project templating toolkit. If I find time I would give this also a try. Just check the links to get some inspiration.


1 comment to Maven & Flex-mojos