I am trying to build a flex library project that I can reuse in a couple of projects that we have. Hey this beats the normal let me copy this file over and such that I have been seeing. So I first of course copied over the files that were common removed anything not common and started doing the normal cleanup. Then I started working on the build script. So I created the normal ANT script items and a clean-up target. Then I started on my build target, first I realized that I need to read up on this since it is not the normal MXML compiler.
So after reading several items about COMPC I realize that I need to pass in a space delimited list of file names. For example: com.eric.util.Converter com.eric.util.Utils. At first I was like what you have to be kidding me there is no way, what if someone on the team adds or deletes and file and forget to do this what a maintenance nightmare. I thought this must be wrong so I dug a bit deeper and tried a trick or two with no luck at all. So I Googled and chanted a bit to which I found numerous sites referring to ANT tasks that look for file names and then create this. Hallelujah the heavens open up and all is right in the world. So after a bit of playing around here is what I came up with thanks to numerous sites and a guy at work.
<target name="-resolve-class-path" depends="clean"><path id="list_1"><fileset dir="${basedir}/src"><include name="**/**"/><exclude name="**/.copyarea.db"/><exclude name="**/**.bak"/><exclude name="**/**.keep"/><exclude name="**/**.contrib"/></fileset></path><pathconvert property="project_classes_property" pathsep=" " dirsep="." refid="list_1"><map from="${basedir}/src/" to=""/><mapper><chainedmapper><globmapper from="*.as" to="*"/></chainedmapper><chainedmapper><globmapper from="*.mxml" to="*"/></chainedmapper></mapper></pathconvert><echo>${project_classes_property}</echo></target><target name="compile" depends="clean,-resolve-class-path""><compc output="${basedir}/CommonLibrary.swc" include-classes="${project_classes_property}"><source-path path-element="${flex-src.dir}"/><compiler.include-libraries dir="${flex-libs.dir}" append="true"><include name="Cairngorm.swc"/><include name="Degrafa_.2.11.swc"/><include name="flexlib.swc"/></compiler.include-libraries><compiler.library-path dir="${flexsdk.dir}/frameworks" append="true"><include name="libs" /></compiler.library-path><include-file name="BarLoader.swf" path="${flex-src.dir}/assets/swf/barLoader.swf"/><include-file name="main.css" path="${flex-src.dir}/assets/css/Portal.css"/></compc></target>
The –resolve-class-path target basically looks in the src folder and gets a list of all the files minus a few of them that we do not need. It then strips off the .mxml and .as and also breaks it down to the package name without the src on it.
From there it is a normal build script.
No comments:
Post a Comment