我正在嘗試使用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