Building AIR applications

Flexmojos has now native support to AIR applications:

https://github.com/velo/flexmojos/tree/flexmojos-4.x/flexmojos-testing/flexmojos-test-harness/projects/concept/simple-air

Flexmojos native support for Flex 4 AIR applications:

It is possible to update the simple-air project referenced above to use Flex 4. In order to do so, first set your flex.version to a Flex 4 version (e.g. 4.0.0.14159), and then update the root pom. See the snippet below (the addition is that adt is explicitly added with the version and the dependency for the air-framework is not hard-coded to 3.2.0.3958).

pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>info.rvin.itest</groupId>
  <artifactId>simple-air</artifactId>
  <version>1.0-SNAPSHOT</version>

  <packaging>pom</packaging>

  <modules>
    <module>air</module>
    <module>swf</module>
    <module>swc</module>
  </modules>

  <build>
    <sourceDirectory>src/main/flex</sourceDirectory>
    <plugins>
      <plugin>
        <groupId>net.flexmojos.oss</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <version>${flexmojos.version}</version>
        <extensions>true</extensions>
        <dependencies>
          <dependency>
            <groupId>com.adobe.flex</groupId>
            <artifactId>compiler</artifactId>
            <version>${flex.version}</version>
            <type>pom</type>
          </dependency>
          <dependency>
            <groupId>com.adobe.flex.compiler</groupId>
            <artifactId>adt</artifactId>
            <version>${flex.version}</version>
            <scope>compile</scope>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <!-- Air SDK dependencies -->
    <dependency>
      <groupId>com.adobe.flex.framework</groupId>
      <artifactId>air-framework</artifactId>
      <version>${flex.version}</version>
      <type>pom</type>
    </dependency>
  </dependencies>

</project>

Sample pom.xml for Flex 4 AIR Application

The sample pom.xml file below is a working example to allow you to build a Flex 4 AIR application. Note that with this xml
the version number as specified will not automatically get set into the package unless you place the special version token in your application descriptor. See the snippet below for example.

pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://
maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mcgraphix.xd</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<name>my-app Flex</name>
<properties>
   <!-- the application name which must match the main mxml file
	and application descriptor file names -->
   <application.name>MyApp</application.name>
   <flex.framework.version>4.0.0.14159</flex.framework.version>
   <keystore.file>${basedir}/cert.p12</keystore.file>
   <keystore.password>secret</keystore.password>
</properties>
<packaging>swf</packaging>
<build>
 <sourceDirectory>src/main/flex</sourceDirectory>
 <plugins>
  <plugin>
    <groupId>net.flexmojos.oss</groupId>
    <artifactId>flexmojos-maven-plugin</artifactId>
    <version>${flexmojos.version}</version>
    <extensions>true</extensions>
    <dependencies>
      <dependency>
        <groupId>com.adobe.flex</groupId>
        <artifactId>compiler</artifactId>
        <version>${flex.framework.version}</version>
        <type>pom</type>
      </dependency>
      <dependency>
         <groupId>com.adobe.flex.compiler</groupId>
         <artifactId>adt</artifactId>
         <version>${flex.framework.version}</version>
      </dependency>
    </dependencies>
    <configuration>
      <!-- set this to true to allow the plugin to find the special Flex Builder/Flash Builder
      string in the application descriptor which is normally in site the <content> tag. If you set
      this to false or omit it entirely, the plugin will expect there to be an ${output} token
      in that tag. Placing that token in the application descriptor will prevent the Export Release
      Build function in Flex Builder/Flash Builder for working
      -->
      <flexBuilderCompatibility>true</flexBuilderCompatibility>

      <sourceFile>${application.name}.mxml</sourceFile>
      <descriptorTemplate>${basedir}/src/main/flex${application.name}-app.xml</descriptorTemplate>

      <keystore>${keystore.file}</keystore>
      <storepass>${keystore.password}</storepass>

      <!--optionally include files in the AIR package -->
      <includeFileSets>
            <fileSet>
              <directory>src/main/resources/embedded</directory>
              <includes>
                 <include>*.*</include>
              </includes>
            </fileSet>
      </includeFileSets>
    </configuration>
    <executions>
      <execution>
            <goals>
               <goal>sign-air</goal>
            </goals>
      </execution>
    </executions>
   </plugin>
 </plugins>
</build>
<dependencies>
<dependency>
  <groupId>com.adobe.flex.framework</groupId>
  <artifactId>air-framework</artifactId>
  <version>${flex.framework.version}</version>
  <type>pom</type>
</dependency>
</dependencies>
</project>

Here is the application descriptor for use with the above pom.xml. Note that I removec all the optional nodes and comments which are normally in this file when you let Flex Builder/Flash Builder create it.

MyApp.app.xml
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<application xmlns="http://ns.adobe.com/air/application/1.5.3">
	<id>com.mcgraphix.xd.MyApp</id>
	<filename>MyApp</filename>
	<name>My Application</name>
        <!-- Note that this will not break Export Release Build but when your build is packaged, its version will be set to the string "${version}". This is fine for testing but would not make sense to leave in the actual release -->
	<version>${version}</version>
	<initialWindow>
           <!-- If you use this syntax, you do not need the flexBuilderCompatibility configuration parameter in the pom.xml. However, this will prevent Export Release Builder in FB from working correctly.
	   <!-- <content>${output}</content>-->

           <!-- When using this syntax, you must set flexBuilderCompatibility configuration parameter to true in the pom.xml. This will also allow Export Release Build to function correctly -->
           <content>[This value will be overwritten by Flex Builder in the output app.xml]</content>
	   <width>800</width>
	   <height>600</height>
	</initialWindow>
</application>