ActionScript Maven Build for Air and Android Packages

In the previous posts we’ve covered the basic build automation and how to add libraries and fonts to it.

For many projects, building a SWF is simply not enough so we’ll try to extend the basic ActionScript Maven build presented in the first post. First we will address building Adobe Air packages and then we will address building Android packages. As a general note, please change pom.xml information to suit your build.

To get the Adobe Air package we must instruct FlexMojos to do it by adding the following goal to its execution goals

<goal>sign-air</goal>

Air packages require a valid signing key. Identity information from the key will show up when a user will install the package. To set this up we need to set the signing key information in the configuration section

<keystore>signingKey.p12</keystore>
<storepass>signingKeyPassword</storepass>

and the dependencies to build it in the plugin dependency section

<dependency>
	<groupId>com.adobe.air.compiler</groupId>
	<artifactId>adt</artifactId>
	<version>17.0</version>
</dependency>

Dont’t forget to set the proper Adobe Air version for your project.

Additionally, you may want to include assets for your build which can be done in the plugin configuration like this

<includeFileSets>
	<fileSet>
		<directory>src/assets</directory>
		<includes>
			<include>*.png</include>
			<include>*.xml</include>
			<include>*.ttf</include>
		</includes>
	</fileSet>
</includeFileSets>

In order to test that the Adobe Air package builds nicely just run

mvn clean install

and you should see the Air package next to the SWF.

Next we move to the Android package. Getting this one to work involves more steps. Unlike the Air package, I was unable to build the Android package on Linux because of problems compiling one of its dependencies (adt-maven-plugin). However I had no problem compiling it on a Mac.

First thing is to build native-dependency-maven-plugin-base which is a dependency for adt-maven-plugin.

git clone https://github.com/yelbota/native-dependency-maven-plugin-base.git
cd native-dependency-maven-plugin-base/
mvn clean install

After it we download, modify and build adt-maven-plugin.

git clone https://github.com/yelbota/adt-maven-plugin.git
cd adt-maven-plugin/
vim pom.xml

We need to change the pom.xml to reflect the correct version of native-dependency-maven-plugin-base so look for

<dependency>
	<groupId>com.yelbota.plugins</groupId>
	<artifactId>native-dependency-maven-plugin-base</artifactId>
	<version>1.1</version>
</dependency>

and change

<version>1.1</version>

to

<version>1.2-SNAPSHOT</version>

and then save. Now you can compile it.

mvn clean install

Now all dependencies have been satisfied for building the Android package and we can edit the application pom.xml in order to add the necessary build instructions. Please add the following in the plugins section:

<plugin>
	<groupId>com.yelbota.plugins</groupId>
	<artifactId>adt-maven-plugin</artifactId>
	<version>1.0.9-SNAPSHOT</version>
	<dependencies>
		<dependency>
			<groupId>com.adobe.air</groupId>
			<artifactId>air-sdk</artifactId>
			<version>${air.version}</version>
			<type>zip</type>
		</dependency>
	</dependencies>
	<executions>
		<execution>
			<goals>
				<goal>package</goal>
			</goals>
		</execution>
	</executions>
	<configuration>
		<sdkVersion>${air.version}</sdkVersion>

		<target>apk-captive-runtime</target>
		<keystore>signingKey.p12</keystore>
		<storepass>signingKeyPassword</storepass>

  		<descriptor>name-app.xml</descriptor>
		<versionNumber>1.0.0</versionNumber>
		<versionLabel>1.0</versionLabel>
		<sampler>false</sampler>
			<includes>
				<include>applicationIcon128x128.png</include>
				<include>someAssets.swf</include>
				<include>someFont.ttf</include>
				<include>someXML.xml</include>
			</includes>
		<includesRoot>src/resources</includesRoot>
	</configuration>
</plugin>

All you have to do now is build the application and the .apk will be in the target directory:

mvn clean install

More on tweaks for your ActionScript Maven build in future blog posts.

Leave a Reply

Your email address will not be published. Required fields are marked *