Instead of the preface
I heard quite a lot about building flex projects using maven, but somehow they didn’t get to try. I got to know maven about a year ago when I got to work on a project whose back-end was going to with the help of maven. The project was heterogeneous: back-end - java, user front-end - flash, administrative front-end - java + js, DB - MySql. Historically, all this was going to somehow. One day, it was decided to translate all this into a unified assembly. I’ll say right away what happened with great reservations, but in the end, the assembly was launched by maven. In the java-world, using maven is almost standard, and if you follow the maven ideology, everything is quite good. That time I managed to translate the flash through running the build ant-script. Now, I wanted to try everything honestly. Who is interested in this attempt, please under the cat.
I started, of course, with the search for plug-ins, which could even simply build a flex project. At first glance, there are plenty of them so that you can pick them up, but everything turned out to be somewhat more prosaic. Most of the projects are either already abandoned or simply missing. In general, poking around in the search, I decided to try the most common. This is a flex-mojos-maven-plugin. I got a little lost here, because there were obviously 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 one is that subsequent projects did not refer to their predecessors in any way (you can see the historical development of the project in the resources, if interested). In the end, the latest version was found. So:
Attempt number one: 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 absolutely not important, 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. Overall, it was a pleasant surprise. Standard maven-generation - clean compile - Fail. We get 4 errors:
[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:4.6.0.23201 in repository.sonatype.org/content/groups/flexgroup 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]
...
That briefly report the inability to resolve dependencies of the plug-in, flex-framework and everything connected with it. It was not the most expected result. Because dependency resolution is one of the strengths of maven. Testing repositories shows that in fact, there is no framework with such coordinates. The first failure.
Attempt number two
I try 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 archetype - Fail.
By and large, there is no big difference in error messages, again no dependencies were found for the plugin. True, this time others.
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. Strangely enough, but this simple action is bearing fruit and the compilation is successful! This is the first successful attempt without special shamanic dances with a tambourine.
When doing a simple conversion via property, I try to switch to the last flex-framework that is in the repository. When upgrading to a different version of flex, you also need to translate the plug-in that is used into it. Learn more about the transition
here . In general: it is not recommended to mix several versions of sdk in dependencies, so you need to carefully monitor what is connected and what else needs to be disabled.
In general, the attempt was successful, we go down the life cycle further - we run tests and package the result.
Run unit tests
mvn clean test - Fail.
The first test run failed. Based on the log, the debugging flash player was not 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 learn that it is necessary to explicitly indicate the path to the debug player. There are two ways: add a path to the system variable PATH, or use a secret property that hooks the plugin. The second is closer to me. Moreover, then you can make a profile for each developer, if required. We try, add a variable with an absolute path to the debug 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 mistake, because launching this test through IDEA is successful, which is good news, since no additional configuration has been made. I'm not sure exactly what influenced the process, but switching to flexunit4 and writing a “real” test completely saved the situation. The test started and ran without any errors in the log!
So the minimum goal is reached: mvn clean package works!
Transition to a “clean” as3 project
Recently, I do not often do exactly flex-projects, more and more often it is as3 projects without using mxml. I continue to adapt the project for these needs. To begin with, we will change the names so that there is no doubt and we will replace the starting class from mxml with as. In the configuration of the plug-in, it makes sense to specify a new start file, because the default is Main.mxml, and after replacing it with Main.as, you will lose the ability to autorun the flash after building and type debug through IDEA, but this is not very pleasant. Please note that you only need to specify the file name. By and large, you can not change the names of the source directory and test directories, but somehow I like it better.
Optimization
The project is not distinguished by an abundance of code, but nevertheless it weighs in debug version 853 b, in release version 613. Let us check what can be achieved using optimization from flexmojos. Apparently, the optimization takes place in several stages (I found 4 files in classes, I think this is the optimization stage). After enabling optimization for debugging, it turned out 391b, even less than the release version. The optimizer is also able to compress pictures of resources, the configuration
quality parameter 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 versions of the plugin (net.flexmojos.oss), for version 5
unit testing does not work, and for 6 the compiler is not found in the repository (although there is a
tool , which seems to allow any flex-sdk to maneuver). But even with the current function, it’s not very bad.
Work with fla-resources
Resolving dependencies is one of the very big advantages of maven when they are available in public repositories and a problem when not. When developing (especially games), many resources are stored in svik, obtained from fla-projects. Deploy them every time a special desire does not arise. And if there are many svikov, then in general it would be convenient to convert them in batches. What can be found here?
And here it is to find something special and not something, to my great regret. Although Adobe has switched to the new fla format, which is actually ziped xfl, but there is still no console utility for compiling this good in swc / swf (and probably will not). The search gave a few not very active projects, which currently can not even be considered as alternatives.
So, without FlashIDE, resources cannot be compiled. It is frustrating. Opportunities that are:
- jsfl - with its help you can send fla to the publication in FlashIDE. You can add to this script for placement in the maven-repository, then it will not violate the ideology of maven. True, we get a non-portable script configuration, since it is tied to absolute paths. Also, everyone who works with the project needs FlashIDE. Not the best solution, but at least something. With active work with the designer, it is probably easier to make a common repository and give the designer a script for publishing the svik, although, of course, this is not exactly the work of the designer.
- start compiling fla via Ant or in any other way (for example, FlashDevelop).
But all these methods, in fact, somewhat violate the ideology of the work of maven. Those. Without additional gestures, working with the designer will not work.
Yes, at the same time about fla and version control. Although now it is not a binary format, it is still problematic to merge it, because each save causes rather large-scale diffs, which are not always merge automatically. So, here is the choice of each. If the number of people working with fla is simultaneously 1, then you can try to save on version control and use xfl. True, I do not think that the benefits will be very large.
FlexPDM
I would like to finish the plugin to determine the quality of the code. I found it by chance when I was looking for the possibility of compiling fla-files. FlexPDM is a opensource from Adobe, which is based on a similar java project. The documentation leaves much to be desired, the wiki is not added and scattered around the project. But finding the page with the use was possible. I also found reviews and examples of application in real projects. As usual, I took the latest version (1.2) of the plugin from the Adobov repository: mvn site - Fail (even once I got used to this result)
[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: com.adobe.ac.pmd.maven.FlexPmdReportMojo.canGenerateReport()Z
That's such a nuisance. A small search showed that this plugin in the latest version is not operational. We try to roll back a few versions back and it does not help. In general, this is logical and the explanation is
here .
Having a little more rummaged in Google, I found the Alex Manarpies repopository, which also has version 1.2 of the plug-in, a little later. I clean the local repository, change the rep - mvn site
[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 com.adobe.ac:flex-pmd-maven-plugin: Plugin com.adobe.ac:flex-pmd-maven-plugin:1.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.adobe.ac:flex-pmd-maven-plugin:jar:1.2: Could not transfer artifact com.adobe.ac:flex-pmd-maven-plugin:pom:1.2 from/to flexpmd.opensource.adobe (http://code.google.com/p/flex-maven-repo/source/browse/): Checksum validation failed, expected <!DOCTYPE but is d3ea07a9bcf449ba69929ed4b6c01bdf7b1b9b6d -> [Help 1]
Download failed. The last attempt to work with the plugin snapshot for version 1.3 also failed.
[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 com.adobe.ac:flex-pmd-maven-plugin: Plugin com.adobe.ac:flex-pmd-maven-plugin:1.3-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.adobe.ac:flex-pmd-maven-plugin:jar:1.3-SNAPSHOT: Failure to find com.adobe.ac:flex-pmd:pom:1.3-SNAPSHOT in repository.sonatype.org/content/groups/flexgroup 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]
However, I am glad that some work is apparently being done. Or was conducted. However, besides maven, this project works:
Flashdevelop loversJenkins + Ant - build exampleInstead of conclusion
Flex projects can be flexed with mavens, especially if they 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 a java back-end, then the build will be even better. But for small distributed teams, game development projects, where a lot of designer work, setting up the project is not as simple as you would like. The problem lies in one of the strong parts of maven - resolving dependencies. There are not many repositories, or rather artifacts in them, and they are not consistent. Maven is not yet very popular among flex / flash (especially) developers. Somewhat distressing is the approach of Adoby, which rather does not support the maven build than support it. But sorry, damn handy thing.
The project on which the experiments were conducted , there is also a draft of the article, which was written in the course of the action. By diffs, you can see exactly what and when added.
Resources.
FlexMojos.
The oldest version found. Last updated February 2009Version up to 4.0 is still org.sonatype.flexmojos. Last updated May 2011Version up 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 previous documentation options, so there is not a lot of sense in the first two, but it is much easier to find them than the last one.
The first question and answer archive from google-groupThe second question and answer archive from google-groupAdobe's first article on flexmojos v.4.0-RC2Adobe's second article on flexmojos v.4.0-RC2Adobe's third article on flexmojos v.4.0-RC2Help from IntelliJ IDEA on working with flexmojos v.4.2-betaVersion 4.0 documentationConfiguration options for version 4.0Appach flex wiki - maven pluginFLA / XFL
XFL and version control. Problems.Ant tasks for building a project using Flash CS. year 2009Ant task to work with resources, without compiling them. year 2012Mike Chambers flashcommand is actually a jsfl script generator.FlexPDM
Adobe cookbookWiki - how to invoke FlexPDMFlexPDM maven plugin brokenAlex Manarpies repository