I'm trying to write an ant build script to build my group's flex app, and I've run into some roadblocks that I'm hoping someone on SO has seen before.
We have two projects that we build into SWCs and these components contain resource bundles. One SWC requires the other SWC. We have one project that we build into our application (the SWF) which uses both SWCs.
When I build the SWCs, I get no complaints about resource bundles not being found, and when I open the SWCs in winzip, I can see the bundles (in /locale/EN_US, for example)
When I build the SWF, however, I get complaints about not being able to find the resource bundles in the two swc's, but no complaints about not being able to find any other resource bundles (like the flex framework ones). This is the kind of message I get from ant:
[mxmlc] Error: Unable to resolve resource bundle "whatever" for locale "en_US".
[mxmlc]
Surely, I am not the first person to hit this gotcha, so does anyone know what the problem is here? Am I building the SWCs wrong, or the SWF?
For reference, here's one of my build tasks using compc (for some reason, I can't get the opening target tag to show up)
<path id="facet.sourcePath">
<pathelement location="${flex.facet.src}"/>
</path>
<property name="facet.sourcePath" refid="facet.sourcePath"/>
<echo message="sourcePath is ${facet.sourcePath}"/>
<fileset dir="${facet.sourcePath}" id="facet.sources">
<include name="**/*.as"/>
</fileset>
<pathconvert property="facet.classes" pathsep=" " refid="facet.sources">
<compositemapper>
<chainedmapper>
<globmapper from="*.as" to="*"/>
<globmapper from="${facet.sourcePath}\*" to="*" handledirsep="true" />
</chainedmapper>
<chainedmapper>
<globmapper from="*.mxml" to="*"/>
<globmapper from="${facet.sourcePath}\*" to="*" handledirsep="true" />
</chainedmapper>
</compositemapper>
</pathconvert>
<echo message="classes: ${facet.classes}"/>
<compc output="${flex.lib.output}/${facet.swc.name}" locale="EN_US"
include-classes="${facet.classes}" directory="false"
target-player="10.0.0"
>
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<include-resource-bundles bundle="foo"/>
<include-resource-bundles bundle="bar"/>
<include-resource-bundles bundle="whatever"/>
<sp path-element="${flex.facet.dir}/locale/{locale}"/>
<keep-as3-metadata name="Bindable"/>
<keep-as3-metadata name="Remotable"/>
<keep-as3-metadata name="Embed"/>
<keep-as3-metadata name="Event"/>
<keep-as3-metadata name="ResourceBundle"/>
<source-path path-element="${flex.facet.src}"/>
<compiler.library-path append="true" dir="${flex.framework.lib}">
<include name="*.swc"/>
<include name="../locale/${locale}"/>
</compiler.library-path>
<compiler.library-path append="true" dir="${flex.rsm.lib}">
<include name="*.swc"/>
</compiler.library-path>
</compc>
</target>
and here's my mxmlc task:
<target name="flex.webapp.compile" description="compiles your flex app">
<mxmlc file="${flex.webapp.src}\RSM.mxml"
output="${flex.webapp.deploy}\ant_test\RSM.swf"
use-network="true"
keep-generated-actionscript="true"
debug="true"
locale="en_US"
incremental="true"
actionscript-file-encoding="utf-8"
target-player="10.0.0"
>
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<include-resource-bundles bundle="RSM"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<source-path path-element="${flex.webapp.src}" />
<source-path path-element="${flex.webapp.dir}/locale/en_US" />
<source-path path-element="${flex.rsm.lib}" />
<sp path-element="${flex.core.dir}/locale/{locale}"/>
<sp path-element="${flex.facet.dir}/locale/{locale}" />
<compiler.library-path append="true" dir="${flex.framework.lib}">
<include name="*.swc"/>
<!--include name="../locale/${locale}"/-->
</compiler.library-path>
<compiler.library-path append="true" dir="${flex.rsm.lib}">
<include name="*.swc"/>
<include name="../locale/${locale}" />
<!--include name="rsm_rb.swc" /-->
</compiler.library-path>
</mxmlc>
</target>
Arrgh!
After many hours of staring at this problem, I realized that the issue was looking me in the face the whole time.
The compc task is using 'locale="EN_US"' and the mxmlc task is using 'locale="en_US"'.
If anyone ever posts a "what's the stupidest work problem you've ever had?", this would be my answer.