Maven Unexpected: An Abundance of Flex Mojos
by Tim O'Brien
Adobe Flex 3 SDK: Open Source
For general content related to Rich Internet Applications (RIA), you'll probably want to check out O'Reilly's InsideRIA.com. I'm approaching Flex more from the perspective of a Java developer...
Here we are, a year after the anouncement of JavaFx, and, from where I sit, the energy is still with Adobe's Flex and it has gained more momentum with Adobe's release of Flex 3. Right now, you can download the open source Flex 3 SDK and start compiling and distributing Flex and AIR content without having to pay the piper. The compiler, the debugger, and the framework itself are released under Mozilla Public License v 1.1. To use Flex with Maven, you are going to want to download Flex from the Adobe site
If you want to use the Flex Eclipse plugin, you'll need to fork over some cash. Flex Builder comes in two flavors Standard and Professional. Standard retails for $249 (USD) and Professional retails for $699 (USD). Yikes! Not cheap. The good news is that, unless you are creating a very complex application, you don't really need Flex Builder. I happen to have a copy of Professional around for my own use, but I rarely use it because most of the work I'm doing in Flex these days is less visual and more about delivering data to the Flash client and programmatic creation of UI elements. If you are interested in buying Flex Builder, the main difference between Standard and Professional is that Professional has better testing support and charting/datavisualization components. But, I can't stress this point enough, heavy duty programmers don't really need the fancy UI.
The other thing to know is that there is a healthy community of Open Source that has grown around Flex like osflash.com and a number of projects providing open source components. (I wouldn't be surprised if there is already another alternative Eclipse plugin which provides syntax highlighting and integration with the compiler. I just haven't found it yet.)
Building Flex with Maven
Look around, you'll see that a number of Java developers have blogged about integrating Flex with Java, here's a survey:
- Probably the most recent, and the most interesting is Sebastien Arbogast blogging about his "full stack". He's got a rundown of using the flex-compiler-mojo to build an application that includes Flex/BlazeDS/Spring/Hibernate/MySQL. Anyone interested in using Flex and Maven should read Part I of Sebastien's series.
- If you are looking for a whole application - check out igenko. If you are interested in seeing a working multi-module Maven project that uses the israfil-mojo. Browse the source of this application.
- Jacob von Eyben has created a Maven archetype which you can use to quickly put together a project that compiles Flex into SWC or a SWF. He has also created an archive that shows you how to create a Maven multi-project which copies a SWF artifact to a project with war packaging.
- Tony Hillerson provides an example of using the Maven AntRun plugin to build a Flex project on the InsideRIA blog. While this approach works, I think you'll find using a Maven Plugin dedicated to the Flex compiler a better solution.
Personally, I used Eyben's archive as a starting point, and I've extended it using the israfil-mojo plugin to involve several projects of packaging SWF that all depend on a shared SWC. These SWFs are then copied into the WAR file during the packaging phase. This approach is useful, but if you are interested in using Adobe's Flex Builder you should know that you may run into some problems. From my own experience, it appears that projects that don't conform to Adobe's file layout tend to have problems in the UI. (But, then again, I told you I'm not really using the Flex Builder IDE, I just don't need it.)
Arbogast's blog post (which I stumbled on via the Maven developer's list) introduced me to the most recent stab at a decent Flex Mojo flex-compiler-mojo.
|Enunciate also has it's own Flex compiler built-in with it's Maven mechanism, too. It's used to compile it's generated client-side ActionScript code used to access JAX-WS-defined Java service beans via AMF.|
|(Ryan neglects to mention that he created Enunciate).... You've identified the topic of the next blog post. I've seen Enunciate, but I've never taking the time to pick it up and drive it around the block. I think I'm going to do that tomorrow. Last I checked, it has a Maven plugin, right? And, an archetype?|
I think Flex 3 won the RIA's war, From Python with Django to Java with Spring and Maven and to PHP I see a lot of momentum with Flex. JavaFX it's a fiasco, SUN mistake again and who the hell will use Silverlight? meh.
|I don't know how you came to the idea that Maven is/has gained momentum. I see more and more people walking away from it. What's needed is a build environment that works 100% of the time and not 60% or maybe in 2.0.9, 85%. The blog you're pointing to has the following title: "2.0.9 brings a bit of stability to plugin versions". I especially don't like the *bit of stability* part of this sentence.|
I can't wait to try this new mojo for flex 3. I managed to integrate flex 3 compiler into eclipse, so now I really do not need an expensive adobe tool to go with flex :)
|@Jan, 60%, 85%, are you pulling these numbers out of the air? Or, are you pulling them from somewhere else? A few years ago, in teh absence of good documentation, people who had problems with Maven had a right to complain. These days, there are so many good resources on the subject, if you are having a problem with Maven there is a good chance that you are either too impatient to learn the tool or you just don't know how to ask for help. The fact that there are so many people outside of the Maven community writing plugins is a sign that it is just starting to deliver on the promise.|