`

用Maven构建AIR2项目实践记录

阅读更多

-------------------------------------------------------------------------------------------------------------------------------------------------------------------

参考:

Building an AIR Application

-------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

一、相关环境

OS: Ubuntu 9.10

Maven V2.2.1

Flexmojos V3.7.1

Flex SDK 4.1

Adobe AIR 2.0.2 SDK

 

二、 构建过程

1、似乎目前 Flexmojos 还没有公布创建AIR应用的模板,所以通过其SVN获取AIR应用的样例源码:

SVN地址: http://svn.sonatype.org/flexmojos/trunk/flexmojos-testing/flexmojos-test-harness/projects/concept/simple-air/

simple-air 项目结构如下:


 

2、修改 simple-air / pom.xml文件:

      增加 仓库配置 和 Flexmojos 、FlexSDK 版本属性、指定SDK编译版本等,修改后的 pom.xml 如下:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2008 Marvin Herman Froeder Licensed under the Apache License, 
	Version 2.0 (the "License"); you may not use this file except in compliance 
	with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
	Unless required by applicable law or agreed to in writing, software distributed 
	under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 
	OR CONDITIONS OF ANY KIND, either express or implied. See the License for 
	the specific language governing permissions and limitations under the License. -->
<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>

	<properties>
		<flexmojos.version>3.7.1</flexmojos.version>
		<flex.sdk.version>4.0.0.13555</flex.sdk.version>
	</properties>

	<repositories>
		<repository>
			<id>flexmojos</id>
			<url>http://repository.sonatype.org/content/groups/flexgroup/</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</repository>
	</repositories>

	<pluginRepositories>
		<pluginRepository>
			<id>flexmojos</id>
			<url>http://repository.sonatype.org/content/groups/flexgroup/</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</pluginRepository>
	</pluginRepositories>

	<build>
		<sourceDirectory>src/main/flex</sourceDirectory>
		<plugins>
			<plugin>
				<groupId>org.sonatype.flexmojos</groupId>
				<artifactId>flexmojos-maven-plugin</artifactId>
				<version>${flexmojos.version}</version>
				<extensions>true</extensions>
				<configuration>
					<targetPlayer>10.0.0</targetPlayer>
				</configuration>
				<dependencies>
					<dependency>
						<groupId>com.adobe.flex</groupId>
						<artifactId>compiler</artifactId>
						<version>${flex.sdk.version}</version>
						<type>pom</type>
					</dependency>

					<dependency>
						<groupId>com.adobe.flex</groupId>
						<artifactId>adt</artifactId>
						<version>${flex.sdk.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.sdk.version}</version>
			<type>pom</type>
		</dependency>
	</dependencies>

</project>
 

 3、修改 simple-air / air / pom.xml, simple-air / swf / pom.xml , simple-air / swc / pom.xml 文件中的 

%{flexmojos.version}

     为

${flexmojos.version}

 

4、修改 simple-air/air/src/main/resources/descriptor.xml 中的

<application xmlns="http://ns.adobe.com/air/application/1.0">

     为

<application xmlns="http://ns.adobe.com/air/application/1.5">
 

5、编译项目,终端执行:

mvn install  

 

成功后, 在 simple-air/air/target 文件夹下会有成品:simple-air-air-1.0-SNAPSHOT.air,

运行该文件(需已安装AIR runtime),按提示安装并运行,运行结果如下:


   至此,构建过程实践成功。

 

三、 遇到问题与解决

Q1、未修改 simple-air/air/src/main/resources/descriptor.xml 中的

<application xmlns="http://ns.adobe.com/air/application/1.0">

运行 mvn install 时出现错误:

error 305: Intial window content SWF version 10 exceeds namespace version http://ns.adobe.com/air/application/1.0

 

Q2、修改 simple-air/air/src/main/resources/descriptor.xml 中的 namespace为:

<application xmlns="http://ns.adobe.com/air/application/2.0">

运行 mvn install 时出现错误:

error 102: Invalid namespace http://ns.adobe.com/air/application/2.0

 

以上2个错误的原因及解决是相通的:

 

原因:Flash Player , Flex SDK, adt 的版本彼此之间是有关联的,Q1是由于pom.xml指定了Flash Player版本为10 (<targetPlayer>10.0.0</targetPlayer>),  Q2是由于pom.xml指定了Flex SDK为4.0.0.13555(<flex.sdk.version>4.0.0.13555</flex.sdk.version>) ,该版本对应的 adt 版本为1.5。

 

注1:该原因是根据一些资料得出的,更多请参考:

 1) http://help.adobe.com/zh_CN/air/build/WS5b3ccc516d4fbf351e63e3d118666ade46-7ff1.html#WSe3d2d52902616553396777a311d6a2e014f-8000

2) http://forums.adobe.com/message/2894373

注2: 目前 flex.sdk.version 版本似乎最高只能是 4.0.0.13555,仓库中 adt 最高只有这个版本。

 

解决: 将命名空间URL改为:http://ns.adobe.com/air/application/1.5

  • 大小: 12.5 KB
  • 大小: 6.2 KB
分享到:
评论
1 楼 binglang8632 2010-12-11  
你好,谢谢你的分享。想请教一下这种结构如何导入到flashbuilder下,如果是通过mvn flexmojos:flashbuilder来生成项目文件,则会报错:Could not find main application! (Hint: Try to create a MXML file below your source root),请指教,谢谢。

相关推荐

Global site tag (gtag.js) - Google Analytics