FAQ

Q. I get an error when trying to build my project: java.lang.OutOfMemoryError: Java heap space?

A. You need to set the environment variable MAVEN_OPTS to a larger Java heap space value, usually a number between 512 and 1024 MB works the best. For example:

MAVEN_OPTS=-Xmx512m

Q. What is included on Flex SDK released on Flexmojos maven repository?

A. Flexmojos does release the opensource version of FDK, the MPL one. That includes Flex and Air frameworks, spark, rpc, localization, rsls and a few other things included on MPL version.

That mean no font-kit, no license, no agl graphics and obvious no Flashbuilder (former Flexbuilder) components like automation and datavisualization nor LCDS components. If you need any of those you will need to manually install it. Check this for more help.

Q. How to get flexmojos working with a different flex SDK version?

A. To do that, Maven 2.0.9 is mandatory.

Once the desired version is available at flex SDK, is necessary to inform maven to use this new version at 2 distinct points, both on pom.xml.

First change plugin dependency:

 <build>
  <plugins>
    <plugin>
      <groupId>org.sonatype.flexmojos</groupId>
      <artifactId>flexmojos-maven-plugin</artifactId>
      <dependencies>
        <dependency>
          <groupId>com.adobe.flex</groupId>
          <artifactId>compiler</artifactId>
          <version>{your version}</version>
          <type>pom</type>
        </dependency>
        <dependency>
          <groupId>com.adobe.flex.compiler</groupId>
          <artifactId>asdoc</artifactId>
          <version>{your version}</version>
          <classifier>template</classifier>
          <type>zip</type>
        </dependency>
      </dependencies>
    </plugin>
  </plugins>
</build>

Then change project dependency:

 <project>

  <build>...</build>

  <dependencies>
    <dependency>
      <groupId>com.adobe.flex.framework</groupId>
      <artifactId>flex-framework</artifactId>
      <version>{your version}</version>
      <type>pom</type>
    </dependency>
  </dependencies>
</project>

The flex-framework version and compiler version must be the exact same

Q. How do I get rid of the watermark on my datavisualization charts or the automation trial limit?

A. You need to have a valid Flex Builder 3 Professional license key. If you run flex-mojos on a machine that has Flex Builder 3 Professional installed, flex-mojos will automatically detect your license key. If not, then you need to put your license key in your pom like this (the dashes are optional):

 <build>
  <plugins>
    <plugin>
      <groupId>org.sonatype.flexmojos</groupId>
      <artifactId>flexmojos-maven-plugin</artifactId>
      <configuration>
        <licenses>
          <flexbuilder3>nnnn-nnnn-nnnn-nnnn-nnnn-nnnn</flexbuilder3>
        </licenses>
      </configuration>
      <dependencies>
        <dependency>
          <groupId>com.adobe.flex</groupId>
          <artifactId>license</artifactId>
          <version>${flex.sdk.version}</version>
        </dependency>
      </dependencies>
    </plugin>
  </plugins>
</build>

Important: Note that the dependency on license.jar is for the plugin not the project

Now, you need to install manually license.jar on maven repo. Maven will provide detailed install instructions at first time you try to compile this project. {{License.jar is available on the non-MPL Adobe SDK or on the SDK from you Flex Builder installation. To clarify, flexmojos repository only contains with the MPL version of the Flex SDK and doesn't support licensing.

If you still see the watermark, then either the license key is invalid, or you do not have the correct license.jar on the maven classpath when it compiles the Flex project. You can run:

mvn install -X

to show the detailed maven output, and you should see something like this in your build (with or without dashes is fine):

 -licenses.license flexbuilder3 nnnnnnnnnnnnnnnnnnnnnnnn

and

[DEBUG]     com.adobe.flex.compiler:license:jar:3.0.0.477:compile
(selected for compile)

or

 [DEBUG]   (f) pluginArtifacts = [........,
com.adobe.flex.compiler:license:jar:3.0.0.477:compile,......

Q. How do I create a SWC with all test classes?

A. You need to execute the test-swc goal. That can be achieve by adding this on pom:

 <build>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <configuration/>
        <executions>
          <execution>
            <goals>
              <goal>test-swc</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

test-swc goal will reuse all configuration declared on flexmojos-maven-plugin

Q. How to fix font rendering issues?

A. Flex SDK depends on flex-fontkit library to embed fonts. But this library isn't opensource. So is necessary to manually install on maven repo and then inform flexmojos to use it.

First, install flex-fontkit using install-file mojo. It goes like this:

mvn install:install-file -DgroupId=com.adobe.flex -DartifactId=flex-fontkit -Dversion=${flex.sdk.version} -Dpackaging=jar -DgeneratePom=true -Dfile=${flex.sdk.path}/lib/flex-fontkit.jar

Then add the flex-fontkit dependency to flexmojos dependencies:

 <build>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <configuration/>
        <dependencies>
          <dependency>
            <groupId>com.adobe.flex</groupId>
            <artifactId>flex-fontkit</artifactId>
            <version>${flex.sdk.version}</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>

Read more...

Q. How to fix font embedding (transcoding) issues?

A. The default font manager is quite old and the improved version from adobe is not enabled by default because it's not opensource, so you need to activate it through configuration.

As the needed dependencies are not opensource, they are not available on public repos. You need to install the dependencies to your own maven repository or install them in your local repository:

mvn install:install-file -DgroupId=com.adobe.flex -DartifactId=flex-fontkit -Dversion=${flex.sdk.version} -Dpackaging=jar -DgeneratePom=true -Dfile=${flex.sdk.path}/lib/flex-fontkit.jar
mvn install:install-file -DgroupId=com.adobe.flex -DartifactId=rideau -Dversion=${flex.sdk.version} -Dpackaging=jar -DgeneratePom=true -Dfile=${flex.sdk.path}/lib/rideau.jar
mvn install:install-file -DgroupId=com.adobe.flex -DartifactId=afe -Dversion=${flex.sdk.version} -Dpackaging=jar -DgeneratePom=true -Dfile=${flex.sdk.path}/lib/afe.jar
mvn install:install-file -DgroupId=com.adobe.flex -DartifactId=aglj32 -Dversion=${flex.sdk.version} -Dpackaging=jar -DgeneratePom=true -Dfile=${flex.sdk.path}/lib/aglj32.jar

After, just declare the new font manager in your pom.

<build>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <configuration>
          <fonts>
            <managers>
              <manager>flash.fonts.AFEFontManager</manager>
            </managers>
          </fonts>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>com.adobe.flex</groupId>
            <artifactId>flex-fontkit</artifactId>
            <version>${flex.sdk.version}</version>
          </dependency>
          <dependency>
            <groupId>com.adobe.flex</groupId>
            <artifactId>afe</artifactId>
            <version>${flex.sdk.version}</version>
          </dependency>
          <dependency>
            <groupId>com.adobe.flex</groupId>
            <artifactId>aglj32</artifactId>
            <version>${flex.sdk.version}</version>
          </dependency>
          <dependency>
            <groupId>com.adobe.flex</groupId>
            <artifactId>rideau</artifactId>
            <version>${flex.sdk.version}</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
</build>

If you get the error 'exception during transcoding: No FontManager provided', make sure you have declared the dependencies under the flexmojos-maven-plugin and not at the top-level project dependencies.

Q. How do I get help on Flexmojos usage?

A. Basically there are 3 possible choices:
1 - For self studies, reading this Wiki, maven docs site (4.1-beta) and the sources
2 - Using community strength at user list, you can search the forum history at (http://groups.google.com/group/flex-mojos) or ask (flex-mojos@googlegroups.com). BTW, when you got an answer for a very complicated question, you can consider sharing this knowledge on this wiki.

On each way you will get help.

Q. How To Specify Flash Player Target Version?

A. Detailed article located here: https://docs.sonatype.org/display/FLEXMOJOS/How+To+Specify+Flash+Player+Target+Version

Q. When I build it with FlexBuilder/FlashBuilder everything works fine, but when I build it using Flexmojos something goes wrong...

A. Well, obviously something differs from the IDE build and maven build. The most obvious way to figure out where is the difference is comparing the dump config.xml.
On IDE add "-dump-config filename.xml" on Additional compiler arguments under project properties/Flex Compiler.
On Maven set configurationReport to true.
Then compare it using your favorite tool and adjust your until both produces the same result.

Q. What to do if there is no way to get tests working properly?

A. Please refer to: https://docs.sonatype.org/display/FLEXMOJOS/Running+unit+tests#Runningunittests-noway

Q. How can I create and install a Maven dependency in my local repository from a 3rd party Flex component?

A. The easiest way to reference a 3rd-party dependency from a Flex project under Maven is to have the dependency in your pom.xml. Some packages don't offer their code as Maven packages, in which case you can install the primary libraries to your local repository.

This example uses the Adobe Data Visualization framework, which is available on Adobe's site. This framework is actually available in the Sonatype repository:

<groupId>com.adobe.flex.framework</groupId>
<artifactId>datavisualization</artifactId>
<version>4.0.0.13555</version>

The version is not compatible with the code that I'm currently working on, though, so I needed to use the earlier 3.5-compatible version.

The files that you need to place in the repo are the swcs for the target library. In the case of data visualization, these are:

frameworks/libs/datavisualization.swc
frameworks/locale/en_US/datavisualization_rb.swc
frameworks/locale/ja_JP/datavisualization_rb.swc

The first is the main code package for the data visualization library. The other two are resource bundles for localized messages. These all need to be installed in the local repository. The basic command looks like this:

 mvn install:install-file -DgroupId=com.adobe.flex.framework \
    -DartifactId=datavisualization -Dversion=3.5.0.12683 -Dpackaging=swc \
    -Dfile=frameworks\libs\datavisualization.swc

This is pretty self-explanatory. Install a file under the given group and artifact ID with the indicated version. Package it as an SWC. The file to use is the one specified by -Dfile=.

Now you need to install the resource bundles. There are two main differences here:

  • Instead of swc, you want the packaging to be rb.swc.
  • You need to add the -Dclassifier=xx_XX, where xx_XX is the indicated locale, e.g. en_US. The exception to this is that your default resource bundle should be installed twice: once with the classifier and once without.

So the commands for installing the resource bundles shown above look like this:

mvn install:install-file -DgroupId=com.adobe.flex.framework \
    -DartifactId=datavisualization -Dversion=3.5.0.12683 -Dpackaging=rb.swc \
    -Dfile=frameworks\locale\en_US\datavisualization_rb.swc
mvn install:install-file -DgroupId=com.adobe.flex.framework \
    -DartifactId=datavisualization -Dversion=3.5.0.12683 -Dpackaging=rb.swc \
    -Dfile=frameworks\locale\en_US\datavisualization_rb.swc -Dclassifier=en_US
mvn install:install-file -DgroupId=com.adobe.flex.framework
    -DartifactId=datavisualization -Dversion=3.5.0.12683 -Dpackaging=rb.swc \
    -Dfile=frameworks\locale\ja_JP\datavisualization_rb.swc -Dclassifier=ja_JP

Once this is done, you can refer to your new bundle in your pom.xml with a dependency block:

 <dependency>
    <groupId>com.adobe.flex.framework</groupId>
    <artifactId>datavisualization</artifactId>
    <version>3.5.0.12683</version>
    <type>swc</type>
</dependency>
<dependency>
    <groupId>com.adobe.flex.framework</groupId>
    <artifactId>datavisualization</artifactId>
    <version>3.5.0.12683</version>
    <type>rb.swc</type>
</dependency>

 

Q. Is the Maven Plugin Documentation available anywhere?

A. Yes. Flexmojos is currently hosting that inside nexus so multiple versions can be hosted at same time. The root folder is http://repository.sonatype.org/content/sites/flexmojos-site/
Some sample links:

Q. How do I configure the Adobe-signed Flex 4 RSL dependencies?

To avoid runtime loading errors, make sure the Adobe-signed Flex 4 RSL dependencies are listed first in your pom.xml file. You should match the order of the Adobe framework RSLs defined in sdks/4.1.0/frameworks/flex-config.xml by the order of the <runtime-shared-library-path> elements.

The RSL runtime loading sequence matches the Flex compiler SWC linking sequence. The flex-mojos plugin relies on Maven for dependency resolution and sequencing. Maven sequences the dependencies using the order specified in the dependencies section. Maven will use the first matching dependency encountered in the case of duplicates/conflicts.

Here is an example pom.xml snippet.

Q. How can I include/exclude test cases with Flexmojos?

By default flexmojos will include all test classes with the pattern: [*/Test.as, **/Test.as, **/Test.mxml, **/*Test.mxml], so, if you use a different naming pattern for tests you need to inform flexmojos that by using includeTestFiles and/orexcludeTestFiles configurations. Snippet example:

   <build>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <configuration>
          <includeTestFiles>
            <include>**/integration/*IT.as</include>
          </includeTestFiles>
        </configuration>
      </plugin>
    </plugins>
  </build>

Q. When compiling my application everything builds fine, but when I open the application the screen stays white. Why?

Since Flex 4.5.1 an application requires the swfVersion to be set to 11, strangely the default comming from the SDK is still 10. So the solution is to add a "<swfVersion>11</swfVersion>" to the Flexmojos configuration in order to have Flexmojos override this.

   <build>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <configuration>
          <swfVersion>11</swfVersion>
        </configuration>
      </plugin>
    </plugins>
  </build>

Q. I am getting Errors (NullPointerException) when building my war ... why?

There is an issue with Maven 3.0.3 and the scopes (rsl, caching, ...) and packaging types (swf, swc) of Flexmojos. The copy maven resources target usses default Maven functionality to check if there are any "finalName" settings for the referenced swf-resources. Unfortunately the packaging of these swf-modules cause Maven to return null instead of a maven model. This causes the NullPointerException. One solution, if you don't use finalName, is to set an additional config parameter "<useFinalName>false</useFinalName>". This simply skips the entire functionality that seems to be broken.

   <build>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>copy-flex-resources</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <useFinalName>false</useFinalName>
        </configuration>
      </plugin>
    </plugins>
  </build>