Alain Hufkens {Rich Interactive Applications Developer}

21Feb/103

Playing with Maven & NativeProcess API in AIR 2.0

I have been playing with Adobe AIR 2.0 beta 2 for a couple of weeks now. And because we use Maven for our bigger development projects at Nascom, I decided to create a small proof of concept app to wrap the most used Maven commands. Off course Maven is a very powerful asset when building big Java based applications, but for a some of my colleague Flex developers it can be a frustrating experience. Working with the command line is not the preferred thing to do for a developer that is working most of the time on building user interfaces.

So to avoid these frustrations and to experiment with Adobe AIR 2.0 beta 2, I created this small app that calls some of our most used maven commands:

  • mvn flexmojos:flexbuilder (generates the Flex Builder project settings)
  • mvn jetty:run (starts the Jetty webserver)
  • mvn jetty:stop (you will need to and an extra setting in the project's pom.xml file)
  • ...

So what's this post all about?

First it's about the code that uses the new NativeProcess API available in Adobe AIR 2.0 to call Maven commands and process (display) the output of these commands. On the other hand I have built a small tool that could be useful for all you frustrated Flex developers that have to know commands to start and stop servers, and all that magic mojo stuff (Flexmojos). The current example only has a very limited list of commands (see above). But it could be a start for another great productivity app, because with the NativeProcess API  you can now take advantage of almost everything on your OS. Only be aware that when doing this you are mostly writing OS specific code.

How does it work?

Start the application in Flash Builder and drag and drop the pom.xml (this is a Maven project file) file from the root of the project to the app, and then the xml file will be parsed. There are normally al least two modules: a server (war) module and a flex (swf) module. And they each support different commands.

There are however still a couple of issues. So if anybody can help me out here, that would be very appreciated.

  • Because the NativeProcess can't call .bat files directly, you need to use a workaround calling cmd.exe and passing the mvn.bat file as a parameter. It works great while running from Flash Builder. But in the installed app it shows the cmd.exe window. Read more about this issue here. So if anybody has a solution, that would be appreciated.
    • UPDATE 30-10-2010: As you can read in this forum thread, this issue is going to be fixed in the 2.0 release. That's good news, so I might go through with this small little app.
  • At the moment there is only support for windows. Of I figure out how to run the Maven process from a Mac I will add Mac support. More about issue that here.
  • If you run the server and close the app, then the server (java.exe) still keeps running in the background.
  • And it lacks a lot of features, so feedback is welcome.

If you are interested, check out the code on Google Code: it's called The Ma(ven)trix.

Filed under: air, flex Leave a comment
Comments (3) Trackbacks (0)
  1. I’ve been trying to write a similar application for running ANT targets from parsed build files. I came across the same issues as you. Have you learned anything new with regards to this?

  2. The most important issue was resolved (see updated blog). I suppose that there are solutions for the other issues as well, but I don’t seem to have time to continue this project. But if you need any help, I am willing to help you if I can.

    Good luck, and let me know how it turned out.

  3. I completed my proof-of-concept. Its very similar to yours, but its made for running Ant targets. Take a peek: http://blog.nobien.net/2010/06/16/proof-of-concept-a-simple-ui-for-running-ant-targets-built-with-adobe-air-2-0/


Leave a comment


No trackbacks yet.