Q:

How to properly define the Flashbuilder 4.5 Premium license for a maven flexmojo based build?

We have been building our Flex app forever using Maven. Due to the fact that we use RIATest for integration testing we need to create a special test version of the app with the RIATest agent compiled in it and with the Flex automation libraries available. Apparently for the latter we need to provide the flex compiler with our license since this is only available from a version higher than Standard.
Up until Flex 4.0 and RIATest 3.8 this worked fine, we had our license information defined in a flex-config file in the user home directory.
However currently with the combination Flex 4.5 and RIATest 4 we are having problems, the tests always fail with "License not present. With the trial version only limited replays are allowed."
We have tried multiple variations of defining the license key for Flashbuilder 4.5 but we have had no success. Currently our flexmojo configuration in the POM references an external flex-config file and there we try to define the license key.

A:

Using flexmojos 3.8, RIATest 4 and the Flex SDK 4.5.1 we have figured out a solution.
First off it turns out that we had a stray configuration lying around in the 
.adobe/Flex/license.properties

file in the Jenkins user's home directory on the build server. It's important to know that configuration from here gets automatically included in builds by flexmojos. So if you want to make sure you have a nice isolated build with no external dependencies, remove this file.
Then we figured out that we can reference an external flex-config.xml file from the flexmojo configuration like so:
<execution>
  <id>build-release-version</id>
  <phase>compile</phase>
  <goals>
    <goal>compile-swf</goal>
  </goals>
  <configuration>
    <configFiles> 
      <configFile>flex-config.xml</configFile> 
    </configFiles> 
  </configuration>
</execution>

Inside the flex-config.xml file you need to use the following license syntax:
<licenses>
   <license>
      <product>flashbuilder45</product>
      <serial-number>LICENSE CODE</serial-number>
   </license>
</licenses>

And now for the final kicker: the LICENSE CODE we need to use in the serial-number element is NOT the license number that we got from Adobe (and that we use when installing the Flash Builder tooling) but it is a derived form of that license number that can be found for example in the license.properties file of a developer that has Flash Builder installed. This derived license number does not resemble the original license number and has no dashes.
Mysterious.

