Maven + Flex
I wish this were a post explaining how to use Maven with Flex. I’m afraid this is rather documenting the journey. If you’re lucky (and I am lucky too) I’ll have an additional post or two explaining how I got this to work.
—
Update: After getting some help from Velo (the very helpful author of the flex-mojos project) I finally got things working. Only THEN did I come across this blog entry that outlines, well, pretty much everything I was looking for. Thanks Ryan Knight!
—
I’m a big fan of using Ant to build my Flex projects. I have a pretty standard way to setting up my projects now. I’m a copy ‘n paster and when I start a project I drop in my ‘standard’ build.xml file. This puppy will build a .swf (or a .swc with just a few changes), will inject the SVN revision number into the .swf, can document (ASDoc style) the project and will package everything up into .zip files. So now I’m comfortable with it. It’s easy it’s fast. I understand how things work.
But I’m working on a project that is mostly Java. The collection of projects are managed by Maven. And now I’m trying to integrate a couple of Flash projects and I’m kinda lost. The mindset of Maven seems to be quite different than Ant. From what I’m reading online people who like Maven REALLY like Maven. It’s almost a religious thing. And while I can subscribe to the benefits the difficulties I’m having trying to understand everything is frustrating. While Ant is “procedural” (“it’s not a scripting language!”) Maven seems to be “model based”. I guess? It’s driven by POM files (Project Object Model). And (from what I understand) the POM files outline the details of the project and then the commands you execute (build, package, document, even create eclipse project settings) use the properties outlined in the POM file to execute. You don’t outline WHAT you want to do (like you do in Ant) you just outline the details of the project essentially defining HOW.
So in addition to things like source location you also outline dependencies of your project. Dependencies seem to include all kinds of things including, apparently, the Flex SDK. These dependencies are all pulled down from a remote location so that the project can be built without setting up all those dependencies, etc. This remote location could be from the “central Maven repository” or it could be from your own repository. Repositories seem to just be an online directory structure, but it seems that most places seem to use a public SVN location for these repositories. It might be necessary to use SVN, I don’t know. (Can you tell I still have a lot to learn about this?) This would be important as I need to use a specific version of the SDK with some modifications made to it (locale folders added).
In trying to understand Maven I’ve gone through the quick-start guide and even the not-so-quick-start guide. Both are frustrating to me in that so much is just “done for me”. It’s better than nothing, but it’s tough that I’m trying to come it and immediately go to a non-Java project (this is definitely a tool for Java projects). I’m still reading docs and how-tos so I’ll get there.
It seems that there are a few plugin options I have as it comes to Flash projects in Maven. The Flex 2.0 maven plugin would probably get the job done but it doesn’t seem to do all of the cool “auto dependency” thing. This is a very desired thing as I don’t want my Java coding counterparts to have to install the Flex SDK, setup properties, etc if it can be avoidable.
Another option I found on Google Code, maven-flex-plugin seems to be stalled. At the least there are no comments, instructions or anything. There’s a bit of code in the repository but I can’t tell if it’s going to be helpful or not yet.
The last option I’m aware of seems more promising but I can’t get it to work. It’s called flex-mojos and has a Google Code page but most of the activity seems to be on another page. This project at least seems active. It’s on version 2.0+ and the last change was just a couple of weeks ago. The samples provided don’t seem to be working and I certainly don’t know enough to understand why not. It’s probably operator error. And if I can’t even get the sample to work I sure can’t modify it to work in my own projects. This does seem like the best option though and I’ll be looking into it further.
Hopefully I’ll have some more information about Maven and how to use it with Flex! If anybody reading this has some tips then I’m definitely interested in hearing about it!
following with interest, just getting the hang of ant and now this :(