4

I'm converting an existing build script from <mxmlc /> to <compc /> to generate a swc.

However, the build is failing, giving the error:

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

In my ant task, I have the following defined:

    <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>

This approach worked fine with the task, but is now failing.

What's the correct way to use compiler constants with compc?

Marty Pitt
  • 28,822
  • 36
  • 122
  • 195
  • I've hit the same problem and I blame for this a bug of mxmlc compiler that is used in Flash Builder 4. – JabbyPanda Jan 13 '11 at 13:38
  • When I compile using Ant and Flex SDK without Flash Builder 4, I had never encountered this error. When I compile using Ant task within Flash Builder 4 - it is not reliable, sometimes compiling works, sometimes it fails, try to close and open Flex project in this case, try to clean project. – JabbyPanda Jan 13 '11 at 14:06

2 Answers2

5

String values need to be put in single quotes. For instance:

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

The Flex Ant tasks really are incredibly frustrating, mainly due to the lack of documentation. I struggled with this for a while until I figured it out.

Stiggler
  • 2,800
  • 20
  • 21
1

We do something similar in our build, and the only difference I can see is that we don't have the compiler bit:

 <define name="CONFIG::build" value="5" />
zakvdm
  • 479
  • 2
  • 4
  • 14