Building a flex project using maven

Instead of the foreword

I heard a lot about building flex projects using maven, but somehow everyone didn’t get their hands on a try. I met maven about a year ago when I got to work on a project whose backend was going to be with maven. The project was heterogeneous: the back end was java, the user front end was flash, the administrative front end was java + js, and the database was MySql. Historically, all this was going to somehow. One fine day, it was decided to transfer all this to a unified assembly. I must say right away what happened with big reservations, but ultimately maven started the assembly. In the java world, using maven is almost standard, and if you follow the maven ideology, everything is pretty good. At that time, I managed to translate the flash through running the build ant-script. Now, I wanted to try everything honestly. To whom this attempt is interesting, I ask under cat.

I started, of course, with a search for plugins that could even just put together a flex project. At first glance, there are a lot of them to be able to select, but everything turned out to be somewhat more prosaic. Most projects are either abandoned or simply missing. In general, stumbling into the search, I decided to try the most common one. This is flex-mojos-maven-plugin. Here I got a little lost, as there were clearly more than one options. Historically, the project was transferred from one coordinate to another, similarly with repositories and source codes. The most unpleasant thing about this is that subsequent projects did not refer to their predecessors in any way (in the resources you can see the historical development of the project, if interested). In the end, the latest version was found. So:

Attempt number times: net.flexmojos.oss v.6.0.0

Yes, I forgot to mention that the experiment was conducted in IntelliJ IDEA, which has support for both maven and flex. However, this is completely unimportant, all the same could be done from the command line.

As it turned out, IDEA by default knows the archetype for net.flexmojos.oss v.6.0.0. All in all, it was a pleasant surprise. Standard maven generation - clean compile - Fail. We get 4 errors: Which briefly report the impossibility of resolving the dependencies of the plug-in, flex-framework, and everything connected with it. This was not the most expected result. Since dependency resolution is one of maven's strengths. Checking the repositories shows that, in fact, there is no framework with similar coordinates. The first failure.

[ERROR] The project FlexMojosTest:FlexMojosTest:1.0-SNAPSHOT (D:\Projets\FlexMojosTest\pom.xml) has 4 errors
[ERROR] Unresolveable build extension: Plugin net.flexmojos.oss:flexmojos-maven-plugin:6.0.0 or one of its dependencies could not be resolved: Failed to collect dependencies for net.flexmojos.oss:flexmojos-maven-plugin:jar:6.0.0 (): Failed to read artifact descriptor for net.flexmojos.oss:flexmojos-maven-plugin:jar:6.0.0: Failure to find com.adobe.flex:framework:pom: in was cached in the local repository, resolution will not be reattempted until the update interval of flex-mojos-plugin-repository has elapsed or updates are forced -> [Help 2]

Attempt number two

I’m trying to create a similar project, but based on the description from Adobe. It uses an earlier version of the org.sonatype.flexmojos v.4.0-RC2 plugin. Similar actions to create a project from the mvn clean compile - Fail archetype.
By and large, there is no big difference in error messages, again no dependencies for the plugin were found. True, this time different.

Attempt number three

I try another option described in the recommendation from IntelliJ IDEA. It uses version v4.2-beta. This is the latest version of the plugin in this thread, which is available in the repository. Oddly enough, but this simple action is paying off and the compilation is successful! This is the first successful attempt without special shamanistic dances with a tambourine.

Making a simple conversion through the properties, I try to switch to the last flex framework that is in the repository. When switching to another version of flex, you must also transfer to it the plugin that is used. Learn more about the transition here . In general: it is highly recommended not to mix several versions of sdk in dependencies, so you need to carefully monitor what exactly is connected and what else needs to be disabled.
In general, the attempt failed, we go down the life cycle further - run the tests and pack the result.

Running unit tests

mvn clean test - Fail.
The first test run failed. Based on the log, no debug flash player was found. It's nice that right there in the log there is where to turn on this issue. By the link from the log , by the way, this is not the latest version of the documentation, I find out that you must explicitly specify the path to the bargain player. There are two ways: this is to add the path to the system variable PATH, or use the secret property that the plugin picks up. The second is closer to me. Moreover, then it will be possible to make a profile for each developer, if necessary. We try, add a variable with an absolute path to the bargain player and get a new error:

[ERROR] Failed to execute goal org.sonatype.flexmojos:flexmojos-maven-plugin:4.2-beta:test-run (default-test-run) on project FlexMojosTest: Invalid state: the flashplayer is closed, but the sockets still running...

This is clearly progress, although not the best option ... At the same time, this is a plug-in error, because running this test through IDEA is successful, which cannot but rejoice, since no additional settings have been made. I’m not exactly sure what exactly affected the process, but switching to flexunit4 and writing a “real” test completely saved the situation. The test was launched and executed without unnecessary errors in the log!

So the minimum goal is achieved: mvn clean package works!

Transition to a “clean” as3 project

Recently, I do not often do flex projects, more often these are as3 projects without using mxml. I continue to adapt the project to these needs. First, change the name so that there is no doubt and replace the start class from mxml to as. In the plugin configuration, it makes sense to specify a new start file, because Main.mxml is used by default, and after replacing it with, the autoplay of the flash drive after assembly and typical debugging through IDEA will be lost, which is not very nice. Please note that only the file name needs to be specified. By and large, you can not change the names of source directories and tests, but somehow I like it better.


The project does not differ in the abundance of code, but nevertheless weighs 853 b in the release version and 613 in the release version. We’ll check what can be achieved using the optimization from flexmojos. Apparently, optimization takes place in several stages (I found in files 4 files, I think this is the optimization stages). After enabling optimization for debug, it turned out 391b, even less than the release one. The optimizer also knows how to compress resource pictures, the quality parameter of the configuration from 0 to 1 is responsible for this . Most likely, this is an analogue of jpeg quality.

Note Unfortunately, it was not possible to switch to the latest plug-in versions (net.flexmojos.oss),
unit testing does not work for version 5 , and for 6 the compiler was not found in the repository (although there is a tool, which seems to allow you to manipulate any flex-sdk). But even with the current functionality it is already not very bad.

Work with fla resources

Dependency resolution is one of the very big advantages of maven when they are available in public repositories and a problem when not. During development (especially games), a lot of resources should be stored in swiks obtained from fla-projects. Deploy them every time there is no special desire. And if there are a lot of swiches, then in general it would be convenient to convert them in batches. What can be found here?
And here it’s not so special to find, to my great regret. Although Adobe has switched to the new fla format, which is actually xfl-encoded, there is still no console utility for compiling this stuff in swc / swf (and probably will not). The search yielded several not very active projects, which at the moment cannot even be considered as alternatives.

So, without FlashIDE resources cannot be compiled. This is frustrating. Features that are:
  • jsfl - with it, you can send fla to publish on FlashIDE. You can add a script to this to be placed in the maven repository, then this will not violate the ideology of maven. True, we get a non-portable script configuration, since it is tied to absolute paths. Also, everyone working with a project needs FlashIDE. Not the best solution, but at least something. With active work with the designer, it may be easier to make a common repository and give the designer a script for publishing a swik, although, of course, this is not exactly the work of the designer.
  • starting fla compilation through Ant or any other way (for example FlashDevelop).

But all these methods, in fact, somewhat violate the ideology of maven. Those. without additional gestures, working with a designer will not work.

Yes, at the same time about fla and version control. Although now this is not a binary format, it is still problematic to hold it, because each save causes quite large diffs, which by no means always merge in automatic mode. So, here is everyone’s choice. If the number of people working with fla is 1 at the same time, then you can try to save on version control and use xfl. True, I do not think that the benefit will be very large.


I would like to finish the plugin to determine the quality of the code. I found it by accident when I was looking for compilation of fla-files. FlexPDM is an open source from Adobe, which is based on a similar java project. The documentation leaves much to be desired, the wiki is not completed and scattered around the project. But it was possible to find a page using. Also found reviews and examples of application in real projects. As usual, I took the latest version (1.2) of the plugin from the Adobe repository: mvn site - Fail (even somehow I got used to this result) This is such a nuisance. A small search showed that this plugin is not working in the latest version. We are trying to roll back several versions and this does not help. In general, this is logical and the explanation is here .

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.0:site (default-site) on project FlexMojosTest: Execution default-site of goal org.apache.maven.plugins:maven-site-plugin:3.0:site failed: An API incompatibility was encountered while executing org.apache.maven.plugins:maven-site-plugin:3.0:site: java.lang.AbstractMethodError:

Digging a little more in Google, I found the Alex Manarpies repository, which also has version 1.2 of the plugin, a bit later. I clean the local repository, change the rep - mvn site Download failed. The last attempt to work with the snapshot of the plugin for version 1.3 also failed. However, it is encouraging that some work is apparently underway. Or was conducted. However, in addition to the Maven, this project works: For fans of flashdevelop Jenkins + Ant - an example of assembly

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.0:site (default-site) on project FlexMojosTest: failed to get report for Plugin or one of its dependencies could not be resolved: Failed to read artifact descriptor for Could not transfer artifact from/to flexpmd.opensource.adobe ( Checksum validation failed, expected [Help 1]

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.0:site (default-site) on project FlexMojosTest: failed to get report for Plugin or one of its dependencies could not be resolved: Failed to read artifact descriptor for Failure to find in was cached in the local repository, resolution will not be reattempted until the update interval of flex-mojos-plugin-repository has elapsed or updates are forced -> [Help 1]

Instead of a conclusion

It is possible to assemble flex projects with a maven, especially if these are modular projects and the team is large. It is very desirable to have your own repository, with which the team will work. If the project is heterogeneous, especially with java backend, then the assembly will be even better. But for small distributed teams, game-building projects, where there is a lot of designer work, setting up a project is not as simple as we would like. The problem lies in one of the strengths of maven - dependency resolution. There are not many repositories, or rather artifacts in them, and they are not coordinated. Maven is not yet very popular among flex / flash (especially) developers. The Adoby approach, which does not support maven assembly rather than support, is somewhat upsetting. But sorry, damn convenient thing.
Experimented Project, in the same place there is a draft article that was written in the course of action. By the diffs, you can see what exactly and when was added.



The oldest version found. Last updated February 2009.
Version to 4.0 is still org.sonatype.flexmojos. Last update - May 2011
Version to 6.0.0. The most complete documentation. Last update - November 2012 By and large, in the last link I found almost copies of all the previous versions of the documentation, so there is not much point in the first two, but finding them is much easier than the last.

The first archive of questions and answers from google-group The
second archive of questions and answers from google-group

The first article from Adobe on flexmojos v.4.0-RC2
The second article from Adobe on flexmojos v.4.0-RC2
The third article from Adobe on flexmojos v.4.0- RC2

IntelliJ IDEA Flexmojos v.4.2-beta Help

Version 4.0
documentation Configuration options for version 4.0

Appach flex wiki - maven plugin


XFL and version control. Problems.
Ant tasks for building a project using Flash CS. 2009
Ant task for working with resources, without compiling them. 2012
Mike Chambers flashcommand - actually a jsfl script generator


Adobe cookbook
Wiki - how to invoke FlexPDM
FlexPDM maven plugin broken

Alex Manarpies repository

Also popular now: