Talk:Flex Ant Tasks
From Adobe Labs
| Table of contents |
Welcome!
Welcome to the Flex Ant Tasks discussion page on Adobe Labs. Please enter your comments regarding this technology here. To help identify the author of comments, please create a new section and use ~~~~ at the end of your talk entries to automatically create a signature.
Comments should be added in list format, but feel free to add your comment under an existing comment to follow a thread structure. If you are responding to a thread, please use the H3 style for your subject (=== TEXT ===) so that the page is easier to read.
Daniel T 12:30, 24 Jan 2007 (PST)
Question: Ant Version
What version of ant is needed to use this? Is the task compatible with ant 1.6.x or is the new 1.7 version needed?
Thanks,
rkinion 12:09, 25 Jan 2007 (PST)
I'd also like to know the Ant version required...
markmontymark 12:09, 25 Jan 2007 (PST)
Version 1.6.2
The ant tasks might work with earlier versions, but we developed the Ant tasks using 1.6.2.
Paul Reilly 07:39, 7 Feb 2007 (PST)
Ant Task fix for Mac OS X
Under Mac OS X 10.4.8, when I first tried the Ant build example I got the error:
"Command not found: mxmlc"
Searching the Internet I found a solution to the problem on a Japanese website ( [[1]]) using Google Translation ([[2]]) I was able to decipher that to fix the problem you have to set environmental variables for Ant for the Flex SDK and Java home (if a unix guru out there knows why this is necessary please let me know!). Anyway I typed the following into terminal (NOTE: DO NOT TYPE THE "$" AND ">" SYMBOLS, THEY ARE SIMPLY TO SHOW WHEN YOU ARE IN THE SHELL AND WHEN YOU ARE IN PICO):
$ cd
$ pico .antrc
> JAVA_HOME=/Library/Java/Home
> export JAVA_HOME
> PATH=/Developer/SDKs/Flex2.sdk/bin:$PATH
> export PATH
[press 'Control-x']
[press 'y']
[hit return]
Of course, change the Flex SDK path, to the path to the SDK on your machine. Now the ant example should work.
Cheers!
Ans 20:03, 28 Jan 2007 (PST)
I'm having the same issue on XP. Tried this fix there, with no luck. Does anyone else have the mxmlc target working on XP?
--goorange44 13:15, 30 Jan 2007 (PST)
I'm also having the same issue with XP Pro, not sure what else to check.
--SalmonArm 14:42, 31 Jan 2007 (PST)
Same problem on Gentoo Linux here. As the poster below says, the FLEX_HOME must be set:
<property name="FLEX_HOME" value="/opt/flex2"/>
The above property declaration works in Win XP Pro as well when receiving the command not found: mxmlc" failture.
<property name="FLEX_HOME" value="C:\dev\flex_sdk_2"/>
Also, I made the mistake building flexTasks.jar using the ant build script. The resulting flexTask.jar didn't work.
FLEX_HOME
Yah, the FLEX_HOME property isn't designed to be optional. I use the Ant tasks on Windows XP and Fedora Core 5. When I set FLEX_HOME, it works great on both OS's.
Paul Reilly 07:47, 7 Feb 2007 (PST)
I wouldn't recommend putting FLEX_HOME in each ant build file. If it ever changes you have to edit all your projects to get things working again. Kinda like storing the MS Word installation path in each Word file. A second reason is that it breaks cross-platform use. If one developer uses OS-X and the other Linux then the FLEX_HOME paths will differ.
--SalmonArm 22:48, 3 Dec 2007 (PST)
Tasks don't support spaces in paths
My test project had a space in it's parent directory's name, which made mxmlc spit out the error message:
[mxmlc] command line: Error: default arguments may not be interspersed with other options
[mxmlc] Use 'mxmlc -help' for information about using the command line.
Not very useful...
Try using a symbol
Define your path as an ant symbol and use the symbol in the argument. Might work. (For windows paths, sometimes it seems I need to make the symbol a property in an external .properties file. I probably just don't know the right escape sequences/special chars/whatever...) --cluebcke 16:15, 30 Jan 2007 (PST)
Spaces and quoting
I don't think using a symbol is going to help. I suspect the problem isn't with how Ant is processing the arguments, but with how they are being passed to mxmlc. Using mxmlc from the command line with string arguments including spaces requires some quoting trickery. The quoting requirements also vary from Windows to Mac to Linux. We tried hard to make everything that works via the command line also work from the Ant tasks, but I'm sure we missed some edge cases. The good news is that we included the source code, so you can hack up fixes for the cases we missed. Please report fixes back to us, so we can include them in future updates. Thanks.
Paul Reilly 07:58, 7 Feb 2007 (PST)
I am having the same issue. Default path of Flex SDK on MAC has spaces in it
/Applications/Adobe b Flex b Builder b 2 b Plug-in/Flex b SDK b 2/
I tried putting backslash (\) as escape sequence, didnt work
/Applications/Adobe\ Flex\ Builder\ 2\ Plug-in/Flex\ SDK\ 2/
Anyone solved this issue?
david tudury 08:11, 24 Aug 2007 (PDT)
maybe make a symbolic link like:
ln -s /Applications/Adobe\ Flex\ Builder\ 3/sdks/2.0.1/ /usr/share/flex2
then use the path /usr/share/flex2 instead
--ArronH 15:03, 21 Nov 2007 (PST) I've found that I can work around this on Windows by surrounding filenames and paths with double quotes. If I'm calling the java compiler, I can do something like this below where any filenames with spaces are surrounded by quotes:
...
<pathconvert property="compc2.lib.files" refid="@{lib.path.id}" pathsep=",">
<mapper type="regexp" from="^(.*)(\s)*(.*)$$" to='"\1\2\3"'/>
</pathconvert>
<condition property="compc2.libpath" value="-library-path+=${compc2.lib.files}" else="">
<not>
<equals arg1="" arg2="${compc2.lib.files}" trim="true" />
</not>
</condition>
<java jar="${flex.compc.jar}" dir="." fork="true" failonerror="true">
<jvmarg value="-Xmx512m" />
<arg line="@{options} ${compc2.libpath}" />
<arg value="+flexlib=${flex.frameworks.dir}" />
<arg value="-load-config=@{config}" />
<arg value="-source-path=@{src.dir}" />
<arg value="-include-sources=@{src.dir}" />
<arg value="-output=@{dest}" />
</java>
The combination of the <arg line="..."/> and the double quotes allows the argument to get to the flex compiler correctly.
Inconsistent taskdef explanation
The docs says that you should install flexTasks.jar in Ant's lib-directory, and then continues with an example that says to include the path to the jar as classpath into the project's lib directory. The example code then puts in the projects flexTask/lib directory. Quite confusing.
--SalmonArm 15:33, 31 Jan 2007 (PST)
I found that both will work, so you have a choice of either solution. No need to do both.
Ant version requirements
rkinion, markmontymark: We use ant 1.6.2, but newer versions of ant should work.
hth,
matt horn flex docs
danger42 07:40, 30 Jan 2007 (PST)
FLEX_HOME MUST be set
Best guess is that there's a hardcoded reference in the mxmlc task to FLEX_HOME, rather than relying on a fully-parameterized input. Since I already had an exec-style mxmlc task, I already had an sdk home defined and so didn't think I needed to do it again. I finally found that adding FLEX_HOME--although it's not referenced anywhere in my build.xml file--made the "command not found" problem vanish.
Now on to make the rest of it work...
--cluebcke 16:41, 30 Jan 2007 (PST)
ant task for asdoc?
I was using forked java tasks to do flex builds with Ant, but real ant tasks are a great improvement. Thanks Adobe!
However, I would also like to have an ant task for running ASDoc. My guess is, that that one is already on its way. Am I right?
In the meantime, I am using a forked java task to run asdoc:
<property name="asdoc" value="flex2.tools.ASDoc" />
<target name="presentation.apidoc">
<java className="${asdoc}" fork="true" failonerror="true">
<classpath>
<fileset dir="${FLEX_HOME}/asdoc/lib" includes="*.jar" />
<fileset dir="${FLEX_HOME}/lib" includes="*.jar" />
</classpath>
<jvmarg line="-Dapplication.home=${flex.home} -Xms32m -Xmx768m -Dsun.io.useCanonCaches=false -Xbootclasspath/p:${flex.home}/asdoc/lib/xalan.jar"/>
<arg line="-library-path+=${lib}" />
<arg line="-source-path ${basedir}" />
<arg line="-doc-sources ${basedir}/${view.main}" />
<arg line="-main-title ${apidoc.title}" />
<arg line="-window-title ${apidoc.title}" />
<arg line="-output ${doc}/${app.name}-API" />
</java>
</target>
--javamark 07:13, 5 Feb 2007 (PST)
You can use now [http://www.ericfeminella.com/blog/2007/06/07/asdocanttask-project-for-eclipse/ from Eric Feminella to generate AntDoc documentation from Ant --JabbyPandaUA 15:04, 8 Jun 2007 (GMT+2)
Bug Fixes? Here's one.
Where can we send bug fixes? FlexTask.java has a bug where only the first path entry is checked when looking for executables if FLEX_HOME is not set.
Lines 231 and 232 should be switched so the break is within
the conditional, or it exits after the first iteration regardless of outcome. This should fix the reported "Command not found" errors as well.
--notalx 16:18, 5 Feb 2007 (PST)
The code that looks for other executables predates the adding of the FLEX_HOME property. It seems like the proper fix is to remove the outdated executable hunting and report a build error if FLEX_HOME isn't set. I'll try to get this into the next update.
Paul Reilly 08:04, 7 Feb 2007 (PST)
I actually quite like not having to set FLEX_HOME. One less step to getting it all working. Everything else seems to work fine without it. The executables need to be in the user's PATH for normal usage, so it seems logical for the ant task to look there as well.
At any rate, thanks for the fixes!
notalx 12:28, 7 Feb 2007 (PST)
HtmlWrapperTask's resources
There's some inconsistencies in where the html templates are located. In the bundled flexTasks.jar, they are included in /resources/html-templates/, which matches what build.xml and HtmlWrapperTask.java expect and where they live in the flex2 distribution. However, in the FlexAntTask download, they are in resources/.
This causes problems: they are not included in the jar when you compile it from the sources, so they are not found unless the flex2 dir is in your classpath. I find it handy to not have to muck with the classpath, so it seems the simplest and most consistent fix would be to move the template files from resources/ into resources/html-templates/ in your distro. Probably what you intended in the first place.
Thanks for providing the ant tasks. They're really useful for us command line junkies!
I fixed this a few days ago. The fix will be included in the next update. Thanks for reporting it.
Paul Reilly 08:06, 7 Feb 2007 (PST)
mxmlc task does not fail on error
this is amazing! All mxmlc tasks result in a successfull build. I have not yet used any of the other flex ant tasks, but the mxmlc task does noet fail on an unsuccessfull compilation.
--javamark 13:36, 6 Feb 2007 (PST)
mxmlc task does not fail on error (2)
Did I overlook an mxmlc task property (comparable to the failonerror property of the java task)?
--javamark 01:15, 7 Feb 2007 (PST)
I fixed this a few days ago. The fix will be in the next update. Thanks for reporting it.
Paul Reilly 08:08, 7 Feb 2007 (PST)
Maven support
A little offroad question here. Any thoughts about extending support to Maven.
Next release schedule?
I was planning to convert my Flex project to use the Flex Ant Tasks today but, judging from these posts, I should wait until the next release is made available. Any idea when that will be?
TomBaggett 11:17, 13 Feb 2007 (PST)
Compc Task
If you have a large set of class source in a namespace to be compiled to SWC file, you can use a manifest file to avoid having to type an all classes ?.
include-classes without pattern matching
So, what was the rationale behind designing the compc task in such a way that it is impossible to use any of the benefits of Ant?
Without being able to use pattern matching to specify the classes to include there is no point with the task. Having a separate config file isn't really an option, since I still would have to maintain the list by hand.
Is there any plans on fixing the compc task? Is it possible to provide code to help you out?
A solution purely in Ant, using pathconvert, is http://snippets.dzone.com/posts/show/3627
Edit: sorry, I think I wrote this without thinking it through properly. What I'm referring to is the include-classes directive of the compc task. To have to add the classes by hand it the way you have to now is not very scalable, and I would like to be able to do it with some pattern matching. However, I now realise that that isn't as easy as I thought, since it's class names, not paths that are specified.
I still would like some kind of pattern matching capability in the include-classes directive, but I guess that is more an issue with the compc tool than the compc task.
Tasks without exec
Since mxmlc and compc are written in Java, wouldn't it be appropriate to create a compiler in memory instead of doing the exec-behind-the-scenes as the tasks do now? That would do away with the need to set FLEX_HOME (although you would instead have to include that in the classpath, but that is more natural in Ant). Is it at all possible to do this? Is the mxml compiler java class designed to be used only from the command line, or can it be run in-memory as javac can?
Step by Step for Newbies
I am a newbie to Eclipse and Ant. I know what ANT is but I do not understand the instructions on this page from this point on, http://labs.adobe.com/wiki/index.php/Flex_Ant_Tasks#Using_Flex_Ant_tasks.
For example, here is a few questions that come to mind as I read the instructions. Quote: To use the custom Flex Ant tasks in your Ant projects, you must add the flexTasks.jar file to your project's lib directory (my project doesn't have a lib directory. what do i do now?), and then point to that JAR file in the taskdef task (what are you talking about? i've never done that and don't know how). In addition, for most projects you set the value of the FLEX_HOME variable so that Ant can find your flex-config.xml file (don't know why or how to do that?).
These are just a few questions I had as I read these instructions. I am a newbie. Sue me.
Eclipse configuration
Here's the generalization of what I did:
Step 1: Create ant-build Folder in your project
- Right click on your project name and click New.. Folder...
- For the sake of the example, call the folder "ant-build".
- Copy the lib folder from Adobe's flex_ant_tasks_mmddyy.zip to this new folder. The jar file in this lib directory can really go anywhere on your file system, but this is a good enough place for it while getting started.
Step 2: Update Ant Runtime Preferences in Eclipse
- Update the Ant classpath.
- Go to Window... Preferences.... Expand the Ant entry on the left and click Runtime.
- Under the Classpath tab, click Global Entries. Then click Add External jars and add the flexTasks.jar file in the ant-build/lib folder created in Step 1.
- If Eclipse gives you a warning about missing a tools.jar file, refer to this site for guidance: http://www.dynamicobjects.com/d2r/archives/002591.html
- Map the Flex Tasks to the correct class. In this step, you are essentially configuring Eclipse with the mappings from the flexTasks.tasks file.
- Under the Tasks tab, click Add Task...
- In the name field, enter "mxmlc" (without the quotes).
- In the location dropdown, select the flexTasks.jar file from Step 1, #3.
- In the directory tree that appears, select /flex2/ant, and then select MxmlcTask.class.
- Click OK to add the Flex task.
- Repeat for "compc" and "html-wrapper", if you plan to use these tasks.
- Click OK to apply and exit the Preferences window.
Step 3: Customizing the build.xml
- Under the "ant-build" folder, create a build.xml file.
- Copy the sample build file below into this file:
- Make sure the FLEX_HOME property points to the Flex SDK on your machine. If you installed the Flex Builder plugin, by default, it is located in C:\Program Files\Adobe\Flex Builder 2 Plug-in\Flex SDK 2\
- PROJECT_HOME should point to your Flex project on the file system.
- MAIN_SOURCE_FOLDER should be the location of your source files. And OUTPUT_FOLDER should be where the swf files are created when you run a build. These 2 properties correspond to the entries of the same name, under the Flex Build Path section of the project properties.
<?xml version="1.0" encoding="utf-8"?>
<project name="My App Builder" basedir=".">
<property name="FLEX_HOME" value="C:/flex/sdk"/>
<property name="PROJECT_HOME" value="C:/flex/workspace/MyFlexProject"/>
<property name="MAIN_SOURCE_FOLDER" value="${PROJECT_HOME}/src"/>
<property name="OUTPUT_FOLDER" value="${PROJECT_HOME}/bin"/>
<target name="main">
<mxmlc file="${MAIN_SOURCE_FOLDER}/Main.mxml" output="${OUTPUT_FOLDER}/Main.swf" keep-generated-actionscript="true">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${MAIN_SOURCE_FOLDER"/>
</mxmlc>
</target>
</project>
I hope that helps someone.
history.swf not loaded
history.swf builded by the html-wrapper task doesn't work. It has different size with the original .swf from the resouces (2 675 vs 2 656) and does not load.
Bug in html-wrapper task
The html-wrapper task does not respect the basedir property of the ant script. All other ant tasks (including compc and mxmlc) respect this property, but if you try to call a build script that uses html-wrapper via the <ant> task or by launching ant from a different directory, it will generate the index.html file in the working directory.
Does anyone have a workaround for this?
How to use 'include-namespaces' with compc task?
I created the following Ant script:
<target name="compile CustomFlexLibrary SWC"> <compc output="${CustomFlexLibraryBin.dir}/CustomFlexLibrary.swc" locale="en_US"
<source-path path-element="${CustomFlexLibrarySource.dir}"/>
<namespace uri="http://www.company.com/2007/mxml" manifest="${CustomFlexLibrarySource.dir}/customFlexLibrary-manifest.xml"/> <include-namespaces uri="http://www.company.com/2007/mxml"/> </compc> </target>
I receive an error in return: Error: unknown namespace 'http://www.company.com/2007/mxml'
Why?
JabbyPandaUA 20:15, 19 Apr 2007 (GMT +2)
Flex Ant Tasks for Apollo
Hi, Can we use Flex Ant Tasks for Apollo SDK ? Thanks
Loading flex-config takes ages
I think the flex Tasks are excellent, but theres just one obstacle for using it in the development environment for our case. The compiling takes an extremely long time, 10-25 seconds for our application. And it all seems because of the loading of the flex-config.
Has anyone else experienced this, or are we perhaps doing something substantially wrong in our setup?
> I guess 10-25 sec is a time of SWF compilation and has nothing to do with loading of 'flex-config.xml' file
Custom wrapper task template?
Hi, As far as I understand the wrapper task templates are created with flexibility in mind, but I think its strange that we don't have a custom template-source-dir attribute, that overrules the template/history attributes. As an example, you might want to use SWFObject as your detection script...
Casper Rasmussen 04:32, 30 May 2007 (PDT)
I would also like to see the ability to specify a template file in this task. We have made some modifications to the template created by Flex Builder and would like those changes to be integrated into our nightly automated build.
--huych02 10:27, 12 Oct 2007 (PDT)
Minor mod to html-wrapper task offered
I have made a minor custom modification to the html-wrapper Ant task to allow you to specify a filename. If not specified, it will default to the current value of index.html. It allows you to declare in your Ant target a different html filename if you wish. I'd be happy to send the source for this minor modification if it would be of value to be incorporated into the next version.
JeffBNimble 09:44, 29 Aug 2007 (CDT)
Adding to default loaded flex-config.xml
From the command line you can override the default loaded flex-config.xml or you can add to it by specifying: mxmlc -load-config+=configuration.xml SampleApplication.mxml. From the ANT task documentation some ant mxmlc compiler options can have an "append=true" attribute, that will add to existing values. Is this possible for flex-config.xml values? We want to load an external config file with only the following additions to the flex-config defaults:
<source-path>
<path-element>/yyy</path-element>
<path-element>/xxx/xxx</path-element>
</source-path>
<include-libraries>
<library>/libs/xxx.swc</library>
</include-libraries>
Flex 3 support??
<mxmlc file="as3/granite.mxml"
output="build/granite.swf"
use-network="false"
services="war/WEB-INF/flex/services-config.xml"
keep-generated-actionscript="false"
context-root="${WEBAPP_CONTEXT_ROOT}">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<source-path path-element="as3"/>
</mxmlc>
works fine using flex2 but with flex3 beta I get this error:
[mxmlc] command line: Error: unknown configuration variable 'load-config /Users/novotny/flex3beta/frameworks/flex-config.xml'
[mxmlc] [mxmlc] Use 'mxmlc -help' for information about using the command line.
Try the flexTasks.jar that ships with the v3 sdk
I had this same problem and found a solution here: http://livedocs.adobe.com/labs/flex3/html/help.html?content=anttasks_1.html
Click on the section called Installation under Topics at the bottom.
Basically, use the flexTasks.jar that is in FLEX+HOME/sdks/3.0.0/ant/lib instead of the one linked on labs. When I put that into my ANT_HOME/lib directory that error went away. Now for the other errors....
Ant Build Errors Integrated into Eclipse
Is there anyway to use the Ant Tasks and cause the output of the build to be treated as build errors that could be linked directly to source files included in the project being built? Suppose you do a build and see the following in the Eclipse Console window:
Buildfile: C:\testProj\build\build.xml compile:
[mxmlc] Loading configuration file C:\flex\flex2sdk\frameworks\flex-config.xml
[mxmlc] C:\testProj\src\services\CompWrapper.as(21): col: 11 Error: Incorrect number of arguments. Expected no more than 0.
[mxmlc] super("foo");
[mxmlc] ^
BUILD FAILED C:\testProj\build\build.xml:9: mxmlc - Failed with return code: 1
Total time: 4 seconds
The file/line reference to build.xml:9 is clickable, but the file/line reference to CompWrapper.as(21) is not. Would this require a full-fledged eclipse plug-in to do this or is there some other approach to making this error integrated into the project.
Attributes for runtime-shared-library-path
How do I specify the rsl-url attribute for runtime-shared-library-path? When I try:
<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/framework.swc" rsl-url="/bin/framework_${FLEX_BUILD}.swz" />
I get the error:
The <rutime-shared-library-path> type doesn't support the "rsl-url" attribute.
However, if I remove the rsl-url attribute I get the error:
Error: configuration variable 'runtime-shared-library-path' requires a value for 'rsl-url'
Is my syntax incorrect? Or is this attribute called something else?
Ryan Junee 00:38, 4 Jan 2008 (PST)
- I actually had to read the source to figure this out.
- <runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/framework.swc">
- <url rsl-url="/bin/framework_${FLEX_BUILD}.swz"/>
- </runtime-shared-library-path>
- --leedm777 21:08, 27 Apr 2008 (PDT)
Problem with compc task on linux ('unknown configuration variable compiler.source-path')
Hi, we're using CruiseControl on linux to build our various projects, including a library project. The compc task fails on linux (but works on windows) with the error:
compile:
[compc] Adobe Compc (Flex Component Compiler)
[compc] Version 3.0 build 189825
[compc] Copyright (c) 2004-2006 Adobe Systems, Inc. All rights reserved.
[compc]
[compc] command line: Error: unknown configuration variable 'compiler.source-path .'
[compc]
[compc] Use 'compc -help' for information about using the command line.
I fixed this by changing the compc script as follows:
java $VMARGS -jar "$FLEX_HOME/lib/compc.jar" +flexlib="$FLEX_HOME/frameworks" "$@"
to:
java $VMARGS -jar "$FLEX_HOME/lib/compc.jar" +flexlib="$FLEX_HOME/frameworks" $@
i.e. removing the quotes from the variable arguments passed to Java.
This probably isn't the best way to get this working, but couldn't see another way to fix it.
Thanks.
--brindy666 01:30, 21 Jan 2008 (PST)
YOU ROCK....This same problem exists in the mxmlc file on linux TOO Remove the quotes from the "$@" and everything works great!!!!! THANKS!!!!
How do I dynamically add my assets to a 'compc' task...do I really need to add an <include-file> tag for each of my assets? My list of assets is large and changes options. This needs to be dynamic. Can I pass in a fileset somehow?
I have written an Ant Task that will create a config file that lists the include-file tags for each of your assets. Email me at scott [dot] splavec [at] gmail [dot] com for further information. --Scott.Splavec 06:49, 3 Apr 2008 (PDT)
