I'm using Ant and mxmlc to compile ActionScript classes and MXML into swfs, while maintaining the default organization of a Flex Builder (Flash Builder) project. Many of my ActionScript classes are in project subdirectories, so my project is organized like the following:
MyBigProject
-build-imports.xml
-build.xml
-bin-debug
--src
---flash
---app
----CoolWidget1.swf
---Main.swf
--test
-src
--flash
---app
----build-imports.xml
----build.xml
----CoolWidget1.as
--build-imports.xml
--build.xml
--Main.mxml
-test
This directory structure maintains the default directory structure of a Flash Builder project so I can perform push-button builds from the Flash Builder IDE. I've added the Ant build xml's to this project so I can also build from the command line. I'm trying to create portable ant build scripts that require the least changes to reuse in other projects. I have everything like I want except for deriving relative paths.
The build-imports.xml file at the root of the project contains the following:
<project name="project.root.imports">
<dirname property="project.root.dir" file="${ant.file.project.root.imports}"/>
</project>
While the sub project folders contain build-imports.xml with the following:
<project name="MyBigProject.src.flash.app.imports">
<import file="../build-imports.xml" />
</project>
Notice that sub project build-imports.xml walks up the directory hiearchy till it gets to the root build-imports.xml, and there I set the project.root.dir.
I can then use the ${project.root.dir}/bin-debug to specify where to place my binaries. The only problem I have, is I do not know how to create the same directory structure as what lies under my src folder. I need to be able to derive a relative path or perform some string manipulation to create new directorys.
Considering the above information, how do I take a known path like:
${project.root.dir}/src/app
and derive a directory path like:
${project.root.dir}/bin-debug/app
I've found some information about the Ant-contribu propertyregex task, which would allow some string manipulation, but I'm hoping there is an Ant guru out there that can point to a simple solution. I believe it's highly likely as an Ant novice, I'm simply overlooking the obvious.