2010-12-03 37 views
4

我正在將現有構建腳本從<mxmlc />轉換爲<compc />以生成一個swc。使用編譯常量與<compc /> ant任務

但是,編譯失敗,給人的錯誤:

[compc] C:\xxxx\LogViewer.mxml(32): Error: Access of undefined property VERSION. 
[compc] 
[compc] private static const VERSION:String = CONFIG::VERSION; 

在我的Ant任務,我有以下定義:

<compc compiler.as3="true" output="${output.dir}/${swc.name}.swc" incremental="true" fork="true" maxmemory="512m" compiler.show-deprecation-warnings="false"> 
     <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" /> 
     <source-path path-element="${srcdir}" /> 
     <include-sources dir="${srcdir}" includes="*" /> 
     <external-library-path dir="${swc.libs.dir}" append="true"> 
      <include name="*.swc" /> 
     </external-library-path> 
     <external-library-path dir="${output.common.swc.dir}" append="true"> 
      <include name="*.swc" /> 
     </external-library-path> 
     <compiler.define name="CONFIG::VERSION" value="${build.version}" /> 
     <compiler.define name="CONFIG::RELEASE" value="${config.release}" /> 
     <compiler.define name="CONFIG::DEBUG" value="${config.debug}" /> 
     <compiler.define name="CONFIG::AUTOMATION" value="false" /> 
    </compc> 

這種方式工作得很好重任,但現在失敗了。

使用compc使用編譯器常量的正確方法是什麼?

+0

我碰到了同樣的問題,我責怪這是在Flash Builder 4中使用的mxmlc編譯器的一個bug。 – JabbyPanda 2011-01-13 13:38:33

+0

當我使用Ant和Flex SDK進行編譯而沒有使用Flash Builder 4時,我從未遇到過這個錯誤。當我在Flash Builder 4中使用Ant任務編譯時 - 它不可靠,有時編譯工程,有時會失敗,嘗試關閉並打開Flex項目,嘗試清理項目。 – JabbyPanda 2011-01-13 14:06:15

回答

1

我們做我們的構建類似的東西,我可以看到,唯一的區別是,我們沒有編譯位:

<define name="CONFIG::build" value="5" /> 
4

字符串值必須放在單引號。例如:

<compiler.define name="CONFIG::VERSION" value="'${build.version}'" /> 

Flex Ant任務真的令人難以置信的挫折,主要是由於缺乏文檔。我努力了一會兒,直到我明白了。

相關問題