我正在尝试使用Ant编译我的Flex 4项目。我可以编译主应用程序,我可以编译我的一些模块。任何在子包中都有依赖的模块没有说Error: Type was not found or was not a compile-time constant
。我使用Flash Builder 4在Windows上完成了所有的开发工作,因此我可以编译所有内容,但是我需要将编译工作转移到基于Linux的无头的服务器上(这是Ant进来的地方)。使用Ant编译Flex模块
我创建了一个简单的项目来测试我的问题:
src-> Main.mxml
|->modules
|-> module1-> Module1.mxml
|-> module2-> Module2.mxml
|-> subPackage-> SubClass.as
模块1不使用其他类则Flex框架类,其中单词数有子类的实例。编译主应用程序工作正常,Module1也是如此。当它试图编译Module2时,我得到错误Error: Type was not found or was not a compile-time constant: SubClass.
。
我的全Ant脚本是:
<project name="Test" basedir=".">
<property file="build.properties" />
<target name="properties">
<fail unless="mxmlc">The "mxmlc" property must be set in build.properties.</fail>
</target>
<target name="build-app" depends="properties">
<exec executable="${mxmlc}" dir="${src.dir}" failonerror="true">
<!-- Point to the mxml file -->
<arg line="${app.name}.mxml" />
<!-- Don\t generate debug swf -->
<arg line="-debug=false" />
<!-- Generate optimized swf -->
<arg line="-optimize=true" />
<!-- Don't build incrementally -->
<arg line="-incremental=false" />
<!-- Place the built .swf file in the "bin" directory -->
<arg line="-output '${build.dir}/${app.name}.swf'" />
<!--
Create a linker report that lists all the classes already in the main app
This gets passed to the modules so that they don't load up the shared libs again.
-->
<arg line="-link-report='${temp.dir}/link-report.xml'"/>
</exec>
</target>
<target name="build-modules" description="Build Modules">
<build.module dir="${module.dir}/module1" file="Module1"/>
<build.module dir="${module.dir}/module2" file="Module2"/>
</target>
<macrodef name="build.module">
<attribute name="dir" />
<attribute name="file" />
<sequential>
<echo>@{file}</echo>
<exec executable="${mxmlc}" dir="${src.dir}" failonerror="true">
<!-- Point to the mxml file -->
<arg line="'@{dir}/@{file}.mxml'" />
<!-- Don't generate debug swf -->
<arg line="-debug=false" />
<!-- Generate optimized swf -->
<arg line="-optimize=true" />
<!-- Don't build incrementally -->
<arg line="-incremental=false" />
<!-- Place the built .swf file in the "bin" directory -->
<arg line="-output '${module.build.dir}/@{file}.swf'" />
<!-- Exclude all classes that are already in the main application -->
<arg line="-load-externs='${temp.dir}/link-report.xml'"/>
</exec>
</sequential>
</macrodef>
我完全茫然,为什么这是行不通的。
感谢,
--Ryan
你是什么意思的“分装”?这些类是在同一个基本源目录中,还是不同的? – 2010-11-26 10:00:59
在src目录中有一个名为“modules”的目录,其中有2个名为“module1”和“module2”的目录。 “module2”包含一个名为“subPackage”的目录,其中包含类“SubClass.as”。换句话说,所讨论的3个类是:modules.module1.Module1; modules.module2.Module2; modules.module2.subPackage.SubClass。 – Ryan 2010-11-30 13:47:55