在 <compc /> ant 任务中使用编译器常量

Mar*_*itt 4 apache-flex ant mxmlc compc

我正在将现有的构建脚本从<mxmlc />to转换<compc />为生成 swc。

但是,构建失败,给出错误:

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

在我的 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>
Run Code Online (Sandbox Code Playgroud)

这种方法可以很好地完成任务,但现在失败了。

在 compc 中使用编译器常量的正确方法是什么?

Sti*_*ler 5

字符串值需要放在单引号中。例如:

<compiler.define name="CONFIG::VERSION" value="'${build.version}'" />
Run Code Online (Sandbox Code Playgroud)

Flex Ant 任务确实令人难以置信地令人沮丧,主要是由于缺乏文档。我为此挣扎了一段时间,直到我弄明白了。