Flex Builder allows additional compiler arguments to be set in the compiler options, under properties. It sets the argument;
-services ".../services-config.xml"
Is there a way to set the same argument when using the ant task mxmlc?
Cheers,
Mike
You should be able to set it as an attribute on the mxmlc task:
<mxmlc services="../services-config.xml"/>
Not that I know of.
You could always use the task with subnodes if you still are unable to find it in the docs.
Example:
<exec executable="${mxmlc.exe}" dir="${basedir}">
<arg line="-source-path '${flex2sdk.locale.dir}'" />
<arg line="-locale en_US" />
</exec>
I was having the same issues with the services attribute not being available for use in the ant tasks so I added the option to fix the problem:
<mxmlc file="path" output="path to output" >
<compiler.services>${path-to-services}</compiler.services>
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<compiler.debug>false</compiler.debug>
<compiler.context-root>/PATWeb</compiler.context-root>
</mxmlc>
This is accomplished by the following:
<target name="compileApp">
<mxmlc file="src/app.mxml"
...other options
services="[path to your services-config.xml]"
context-root="[path to where your gateway file is]">
...
</target>
This is how we are currently building the mxml app... which means Christophe was correct.
Most of the compiler options are available as either attributes or tags for the mxmlc task, however some options are missing, or work in somewhat unexpected way. Worst thing is lack of proper documentation for the flex Ant tasks.
Sometimes I find it easier to do this:
<mxmlc file="Main.as" output="bin/app.swf">
<load-config filename="${FLEX_HOME}/flex-config.xml" />
<load-config filename="build/config.xml" />
</mxmlc>
And then specify all the options I want in build/config.xml, at least the syntax is documented better, and you can always use flex-config.xml or air-config.xml from your SDK as a (well-commented) sample.
Related
I am trying to use the flex ant task to build my Flex project.
Before using ant, I ran the mxmlc command like this:
mxmlc -load-config mxmlc_conf.xml src\project.mxml -output bin-debug +libs=<absolute_path_to>3rdparty\libs +<other_token>=<absoulte_path_to_value>
The thing is now I am supposed to use flex ant tasks and it looks like they disabled (or forgot about) the custom tokens like += as I haven't found a way to pass those to the mxmlc task.
I have tried using:
< mxmlc ...>< arg token value="..." />< /mxmlc>
but that doesn't work.
What I am trying to accomplish is to get rid of hard-coded paths in the mxmlc config-file (mxmlc_conf.xml) and at first I used the custom tokens in mxmlc but now I don't know how to pass paths as variables to the config file.
I can accept suggestions.
Thanks a lot in advance.
I'm trying to do the exact same thing (replace hard-coded paths in the config file) and I'm looking for the same solution.
It seems we might have to abandon the mxmlc task and simply use mxmlc from the command line:
<exec searchpath="true" executable="amxmlc"
dir="${project.build.outputDirectory}">
<env key="PATH"
path="${env.PATH}:/Applications/Adobe\ Flash\ Builder\ 4.5/sdks/4.5.1/bin" />
<arg value="-load-config" />
<arg value="../src/main/resources/dumpConfig.xml" />
<arg value="+libs=/absolute/path/to/3rd/party/libs" />
<arg value="-output" />
<arg
value="${project.build.outputDirectory}/${application.name}.swf" />
<arg value="../src/main/flex/${application.name}.mxml" />
</exec>
Something like this should work. I'm just hoping there's a better way (that is, a way we can actually use the mxml ant target!)
I hope that helps someone...
Try this
<target>
<replace file="mxmlc_conf.xml" token="$${libs}" value="absolute/path/to/3rdparty/libs"/>
<mxmlc ...>
<load-config filename="mxmlc_conf.xml" />
</mxmlc>
<replace file="mxmlc_conf.xml" token="absolute/path/to/3rdparty/libs" value="$${libs}"/>
</target>
This should be easy, but I can't find it. I want my .html and .swf files to be named something differently than the project name. Project name is foo, I want the outputs to be bar.html and bar.swf. Thanks.
Flextras was on the right track. You can't change the output filename (even using the "-output" compiler param) if you're compiling in Flash Builder. Not sure why.
The solution that has worked for me has been to use a bit of indirection:
use mxmlc to compile to ApplicationClass.swf
command line copy ApplicationClass.swf to YourCustomSwf.swf
command line run YourCustomSwf.swf
You can do this with either a simple (platform-dependent) build script, or with Flex Ant Tasks. I highly recommend the latter; it's easy to setup, integrates well with Flash Builder, and (as a mostly platform-independent solution) will work in a multi-team multi-OS environment. Here are the above steps as ant tasks that will perform the magic for you:
<project name="sample-build" default="run-your-swf">
<property file="${basedir}/your.properties.file"/>
<target name="compile-your-app">
<mxmlc file="${SOURCE_DIR}/ApplicationFile.mxml" compiler.debug="${IS_DEBUG}" incremental="true" failonerror="true">
<load-config filename="${DEFAULT_FLEX_CONFIG}"/>
<define name="CONFIG::DEBUG" value="${IS_DEBUG}"/>
<define name="CONFIG::FLASH_AUTHORING" value="${IS_FLASH_AUTHORING}"/>
<define name="CONFIG::IS_RELEASE" value="${IS_RELEASE}"/>
</mxmlc>
</target>
<target name="rename-your-swf" depends="compile-your-app">
<copy file="${OUTPUT_DIR}/feed/FeedComponent.swf" tofile="${OUTPUT_DIR}/YourNewSexyFilename.swf"/>
</target>
<target name="run-your-swf" depends="rename-your-swf">
<exec executable="${STANDALONE_FLASH_DEBUG_PLAYER}">
<arg line="${OUTPUT_DIR}/YourNewSexyFilename.swf"/>
</exec>
</target>
</project>
you need only define all ${VARIABLES} I've listed in "your.properties.file", like so:
FLASH_PLAYER_DEBUG=/Applications/Adobe Flash CS5/Players/Debug/Flash Player Debugger.app/Contents/MacOS/Flash Player Debugger
IS_DEBUG=true
(et cetera)
And anyway - what's in a name? A program by any other name, would be as awesome... B-)
I can compile the main application but am having an issue with compiling a nested module.
I have the following application structure:
src
MyApp.mxml
view
MyView.mxml
module
MyModule.mxml
view
AnotherView.mxml
When using the following command
<mxmlc file="${SRC_DIR}/${MODULE_DIR}/MyModule.mxml"
debug="false"
output="${OUTPUT_DIR}/${MODULE_DIR}/MyModule.swf"
locale=""
actionscript-file-encoding="UTF-8"
keep-generated-actionscript="false"
optimize="true"
fork="true"
load-externs="LinkReport.xml"
incremental="false">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<compiler.library-path dir="libs" append="true">
<include name="*.swc"/>
</compiler.library-path>
</mxmlc>
I get the following error:
Error: Could not resolve "view:AnotherView" to a component implementation.
I think the compiler might be having an issue with determining which "view" directory has the right mxml file ..
Any Thoughts? A detailed explaination with an example would be most appreciated.
You need to add your src directory as part of the source-path as well. You basically haven't told the compiler where to find your code.
Does anyone know of a way to use the mxmlc Flex Ant task with a user-defined list of source or library paths?
The user should be able to define an arbitrary list of source and/or library (.swc) paths in an Ant properties file and the build file can use these values in the mxmlc task.
Are there any tricks (maybe use filtering/string replacing) to get this working?
Don't know if this helps, but you can include an external XML in your Ant build file:
<?xml version="1.0" ?>
<project name="test" default="test" basedir=".">
<target name="setup">
...
</target>
<import file="./common.xml" />
</project>
I ran across your question, looking for a way to define the library (and source path) definitions in external files. Looping through a list of defined properties seems somewhat problematic to me, since you would possibly have to define a list of library paths as well as sub-lists of files in each defined path in the list.
Seems that including external files defining the library and various source paths might be a better and just as extensible way to go.
They way I do it is list my source paths, library paths etc. in an external mxmlc configuration file (e.g. flex-config.xml), my more-or-less universal build.xml file just does
<mxmlc file="${app.mainClass}" output="${swf}">
<load-config filename="${air.sdk.config}" />
<load-config filename="${app.config}" />
</mxmlc>
Where air.sdk.config points to the SDK's default config xml and app.config is the app's custom config xml.
I don't know if it is possible to do it from a properties file.
You can use this in your Ant script:
<source-path>
<source-path path-element="my/src/dir" />
</source-path>
<library-path dir="my/libs/dir" append="true">
<include name="*.swc" />
</library-path>
Or maybe develop some Ant module to simulate this from your properties file.
I can't understand why you want to make your properties file dynamic, it is the role of your build.xml normally, but hey :)
I would like to build a flex library project automatically instead of the current process, which involves one of our developers compiling it on his machine and then us checking in the resulting .swc file. It's gross.
I am coming at this from the perspective of a java developer, so I'm having a hard time getting the hang of the compilation tools provided in the Flex Builder 3 application, but here's what I already have:
I have created an ant file that loads the ant task library correctly, and can therefore execute <mxmlc/> and <compc/> tasks.
I have located the source code that I need to build, and know what sort of .swc I want to end up with.
What I want is an ant script that will do the equivalent of these steps:
We build all sources (actionscript and MXML) and assets in the project into an swc file.
The library.swf file is extracted and optimized
So far I have this:
<target name="compile-component" depends="init">
<compc output="${DEPLOY_DIR}/${SWC_NAME}.swc">
<source-path path-element="${FLEX_HOME}/frameworks"/>
<source-path path-element="${SRC_DIR}"/>
</compc>
</target>
However, it's not including any content:
[compc] Loading configuration file /Applications/Adobe Flex Builder 3/sdks/3.2.0/frameworks/flex-config.xml
[compc] Adobe Compc (Flex Component Compiler)
[compc] Version 3.2.0 build 3958
[compc] Copyright (c) 2004-2007 Adobe Systems, Inc. All rights reserved.
[compc]
[compc] Error: nothing was specified to be included in the library
[compc]
[compc] Use 'compc -help' for information about using the command line.
It looks like I need to enumerate every class that I want to include in the library, which is... ludicrous. There must be a better way. How do I do this?
You can do the following... it takes all the files from the source path and converts it to a format that the compc task can then use.
<fileset id="project.test.dir.fileset" dir="${project.test.dir}">
<include name="**/*.as" />
<include name="**/*.mxml" />
</fileset>
<property name="project.test.dir.fileset" refid="project.test.dir.fileset" />
<!-- Convert the test files into a compiler friendly format. -->
<pathconvert property="project.test.dir.path" pathsep=" " refid="project.test.dir.fileset">
<compositemapper>
<chainedmapper>
<globmapper from="${project.test.dir}/*" to="*" handledirsep="true" />
<mapper type="package" from="*.as" to="*" />
</chainedmapper>
<chainedmapper>
<globmapper from="${project.test.dir}/*" to="*" handledirsep="true" />
<mapper type="package" from="*.mxml" to="*" />
</chainedmapper>
</compositemapper>
</pathconvert>
<compc headless-server="true" default-frame-rate="${flex.default-frame-rate}" debug="${flex.compiler.debug.mode}" output="${build.swc.dir}/${test.component.name}.swc" include-classes="${project.test.dir.path}" directory="false">
<source-path path-element="${project.test.dir}" />
&dependencies;
</compc>
We use it to produce swcs for testing purposes.
Lucky for you I JUST solved this problem and was looking for the answer to another problem!
<compc output="${basedir}/mySwc.swc" locale="en_US">
<source-path path-element="${basedir}/src/main/flex"/>
<include-sources dir="${basedir}/src/main/flex" includes="*" />
<load-config filename="${basedir}/fb3config.xml" />
</compc>
The source-path is necessary to tell it what to look at when trying to resolve various references. The include-sources tells it which sources to include (obviously in this case all of them). The load-config is just the -dump-config output from Flex Builder.
Hope this helps!!
You can use Maven. It's a configuration management tool rather than just a build tool. It does rely on your project having a manifest file.