Load variable from a file & pass as arg value in ant build
What I want to do is load the contents of a file and sent it to an mxmlc compiler as an argument parameter.
I can load and read the contents of a file usingloadfile
and setting a property
value say propery="filecontent"
. But the problem is I can pass it into the mxmlc (flex) compiler.
I'm not able to pass it (tried with ${filecontent}
) to the arg line
. Its gives an error: "value contains unknown token 'filecontent'"
How will I pass the contents of the file as a argument value to a compiler argument?
Edit:
The problem is with the include-resource-bundles
arguments. When using command line it works. But using ant build doesn't. Do we need to manually provide the name of resource bundles by generating the resource file?
<exec executable="${MXMLC}" dir="${APP_ROOT}/src" >
<arg line="-locale 'en_US'"/>
.. .. ..
<arg line="-include-resource-bundles 'collections,components,containers,controls,core,effects,formatters,layout,modules,skins,states,styles'"/>
.. ..
I'开发者_如何学运维m trying to replace the arguments via something like:
... ....
<loadfile property="resources" srcFile="${APP_ROOT}/src/resources.txt"/>
... ....
<exec executable="${MXMLC}" dir="${APP_ROOT}/src" >
...
<arg line="-include-resource-bundles '${resources}'"/>
....
</exec>
which doesn't work and gives and error -> command line: Error: configuration variable 'include-resource-bundles' value contains unknown token 'resources'
So how to automate this?
There's nothing obviously wrong with the build file. But the error message suggests that ${resources}
is not set when you call the MXMLC compiler. When an Ant property is not set, the property name (with dollar sign and enclosing curly brackets) is substituted instead anywhere that the property is used.
Can you insert something like
<echo message="Resources: ${resources}" />
after the 'loadfile' to check that that task is working? Note, for example, that if the resources.txt is empty the property will not be set.
精彩评论