flex-mojosを使用してAIRアプリケーションをビルドするためpom.xmlを定義。
Building an AIR Application - FlexMojos - Confluence
を参考にpom.xmlを定義すると良い↓。
<?xml version="1.0" encoding="UTF-8"?> <project> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.sonatype.flexmojos</groupId> <artifactId>flexmojos-air-super-pom</artifactId> <version>%{flexmojos.version}</version> </parent> <groupId>com.domain.sample</groupId> <artifactId>Air</artifactId> <version>1.0-SNAPSHOT</version> <packaging>swf</packaging> <properties> <flex.sdk.version>3.3.0.4852</flex.sdk.version> </properties> <build> <sourceDirectory>src/main/flex</sourceDirectory> <plugins> <plugin> <groupId>org.sonatype.flexmojos</groupId> <artifactId>flexmojos-maven-plugin</artifactId> <configuration> <sourceFile>Air.mxml</sourceFile> </configuration> </plugin> </plugins> </build> <!-- AIR Framework --> <dependencies> <dependency> <groupId>com.adobe.flex.framework</groupId> <artifactId>air-framework</artifactId> <version>${flex.sdk.version}</version> <type>pom</type> </dependency> </dependencies> </project>
AIRアプリケーションをビルドする場合も
[ERROR] C:\sample\src\main\flex\main.mxml:[-1,-1] Unable to locate specified base class 'mx.core.WindowedApplication' for component class 'main'.
といった感じでWindowedApplicationなんて知らないよって怒られる。air-frameworkにすることでamxmlcでコンパイルされるようになる。
mvn install
するとtargetフォルダ直下にswfファイルが生成されている。このswfファイルをFlashPlayerでそのまま開いても
VerifyError: Error #1014: クラス flash.events::NativeWindowBoundsEvent が見つかりません。
と怒られる。とりあえず確認するレベルなら
<?xml version="1.0" encoding="UTF-8"?> <application xmlns="http://ns.adobe.com/air/application/1.0"> <id>AirTest1</id> <version>0.1</version> <filename>main</filename> <initialWindow> <content>./target/Air-1.0-SNAPSHOT.swf</content> <visible>true</visible> <systemChrome>standard</systemChrome> <transparent>false</transparent> </initialWindow> </application>
といったXMLファイルを用意(main.xmlとする)して、
adl main.xml
を実行するとAIRアプリケーションとして起動する。正式なAIRアプリケーションとしてパッケージングするには、先程の
Building an AIR Application - FlexMojos - Confluence
の下部のpom.xmlのようにAIRアプリをパッケージングするために必要な設定及びライブラリを定義したpom.xmlを用意してビルドする必要がある。