You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by OmPrakash Muppirala <om...@gmail.com> on 2013/12/02 20:46:41 UTC
Re: [1/2] git commit: [flex-utilities] [refs/heads/develop] -
beginnings of Ant in AIR
Wow. This is shaping up to be a more awesome project than I had imagined
:-)
Thanks,
Om
On Mon, Dec 2, 2013 at 10:23 AM, <ah...@apache.org> wrote:
> Updated Branches:
> refs/heads/develop 10670665c -> a7871a7d7
>
>
> beginnings of Ant in AIR
>
>
> Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
> Commit:
> http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/322d1c56
> Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/322d1c56
> Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/322d1c56
>
> Branch: refs/heads/develop
> Commit: 322d1c561157a019ae8b9d4c223130530670f6d4
> Parents: 1067066
> Author: Alex Harui <ah...@apache.org>
> Authored: Mon Dec 2 10:20:04 2013 -0800
> Committer: Alex Harui <ah...@apache.org>
> Committed: Mon Dec 2 10:20:04 2013 -0800
>
> ----------------------------------------------------------------------
> ant_on_air/build.properties | 24 ++
> ant_on_air/build.xml | 91 +++++++
> ant_on_air/src/AntClasses.as | 34 +++
> ant_on_air/src/org/apache/flex/ant/Ant.as | 129 ++++++++++
> .../src/org/apache/flex/ant/tags/Condition.as | 75 ++++++
> ant_on_air/src/org/apache/flex/ant/tags/Echo.as | 61 +++++
> .../src/org/apache/flex/ant/tags/IsSet.as | 56 +++++
> ant_on_air/src/org/apache/flex/ant/tags/OS.as | 58 +++++
> .../src/org/apache/flex/ant/tags/Project.as | 111 ++++++++
> .../src/org/apache/flex/ant/tags/Property.as | 99 ++++++++
> .../src/org/apache/flex/ant/tags/Target.as | 97 +++++++
> .../ant/tags/supportClasses/IValueTagHandler.as | 30 +++
> .../ant/tags/supportClasses/NamedTagHandler.as | 50 ++++
> .../ant/tags/supportClasses/ParentTagHandler.as | 50 ++++
> .../flex/ant/tags/supportClasses/TagHandler.as | 84 +++++++
> .../flex/ant/tags/supportClasses/TaskHandler.as | 42 ++++
> .../org/apache/flex/xml/IParentTagHandler.as | 46 ++++
> .../src/org/apache/flex/xml/ITagHandler.as | 34 +++
> .../src/org/apache/flex/xml/ITextTagHandler.as | 29 +++
> .../src/org/apache/flex/xml/XMLTagProcessor.as | 82 ++++++
> ant_on_air/tests/TestTarget-app.xml | 250 +++++++++++++++++++
> ant_on_air/tests/TestTarget.as | 47 ++++
> ant_on_air/tests/test.xml | 75 ++++++
> 23 files changed, 1654 insertions(+)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/build.properties
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/build.properties b/ant_on_air/build.properties
> new file mode 100644
> index 0000000..5fa1580
> --- /dev/null
> +++ b/ant_on_air/build.properties
> @@ -0,0 +1,24 @@
> +<?xml version="1.0"?>
> +<!--
> +
> + Licensed to the Apache Software Foundation (ASF) under one or more
> + contributor license agreements. See the NOTICE file distributed with
> + this work for additional information regarding copyright ownership.
> + The ASF licenses this file to You under the Apache License, Version 2.0
> + (the "License"); you may not use this file except in compliance with
> + the License. You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing, software
> + distributed under the License is distributed on an "AS IS" BASIS,
> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + See the License for the specific language governing permissions and
> + limitations under the License.
> +
> +-->
> +
> +LIBRARY_DIR=bin
> +LIBRARY_NAME=ant_on_air
> +SOURCE_DIR=src
> +DEBUG_FLAG=true
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/build.xml
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/build.xml b/ant_on_air/build.xml
> new file mode 100644
> index 0000000..9515465
> --- /dev/null
> +++ b/ant_on_air/build.xml
> @@ -0,0 +1,91 @@
> +<?xml version="1.0"?>
> +<!--
> +
> + Licensed to the Apache Software Foundation (ASF) under one or more
> + contributor license agreements. See the NOTICE file distributed with
> + this work for additional information regarding copyright ownership.
> + The ASF licenses this file to You under the Apache License, Version 2.0
> + (the "License"); you may not use this file except in compliance with
> + the License. You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing, software
> + distributed under the License is distributed on an "AS IS" BASIS,
> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + See the License for the specific language governing permissions and
> + limitations under the License.
> +
> +-->
> +
> +<project name="ant_on_air" basedir="." default="build">
> +
> + <!--load environment variables prefixed with env -->
> + <property environment="env"/>
> +
> + <!--location of property file -->
> + <property file="${basedir}/build.properties" description="Properties
> for Ant On AIR project" />
> +
> + <!--
> + Properties are immutable so value frozen first time property is
> set.
> + If FLEX_HOME is not set with -DFLEX_HOME=/path/to/flex/sdk on the
> ant command line
> + use the environment variable, if it exists. Else if windows, use
> FLEX_HOME_WIN
> + else use FLEX_HOME_MAC, which are both defined in
> build.properties.
> + -->
> + <condition property="FLEX_HOME" value="${env.FLEX_HOME}">
> + <isset property="env.FLEX_HOME" />
> + </condition>
> +
> + <!--
> + Properties are immutable so value frozen first time property is
> set.
> + If AIR_HOME is not set on the command line with
> -DAIR_HOME=/path/to/air/sdk on the
> + ant command line use the environment variable, if it exists. Else
> if windows, use
> + AIR_HOME_WIN else use AIR_HOME_MAC, which are both defined in
> build.properties.
> + -->
> + <condition property="AIR_HOME" value="${env.AIR_HOME}">
> + <isset property="env.AIR_HOME" />
> + </condition>
> +
> + <!-- additional tasks - mxmlc tag -->
> + <path id="flexTasks.path">
> + <fileset dir="${FLEX_HOME}">
> + <include name="lib/flexTasks.jar" />
> + <include name="ant/lib/flexTasks.jar" />
> + </fileset>
> + </path>
> + <taskdef resource="flexTasks.tasks" classpathref="flexTasks.path"/>
> + <target name="build" depends="init,compile"
> + description="Compiles SWC"/>
> +
> + <target name="init" depends="clean"
> + description="Creates the deploy folders and sets app extension"/>
> +
> + <target name="clean" description="Cleans up old files.">
> + <delete dir="${LIBRARY_DIR}" failOnError="false"
> includeEmptyDirs="true" />
> + </target>
> +
> + <target name="compile"
> + description="Compiles the SWC.">
> + <compc
> + output="${LIBRARY_DIR}/${LIBRARY_NAME}.swc"
> + debug="${DEBUG_FLAG}"
> + failonerror="true"
> + fork="true"
> + maxmemory="512m">
> + <source-path path-element="${SOURCE_DIR}"/>
> + <external-library-path
> file="${AIR_HOME}/frameworks/libs/air/airglobal.swc" append="true"/>
> + <include-classes>AntClasses</include-classes>
> +
> + </compc>
> + <mxmlc file="${basedir}/tests/TestTarget.as"
> + output="${basedir}/tests/TestTarget.swf"
> + debug="${DEBUG_FLAG}"
> + failonerror="true"
> + fork="true"
> + maxmemory="512m">
> + <source-path path-element="${SOURCE_DIR}"/>
> + <external-library-path
> file="${AIR_HOME}/frameworks/libs/air/airglobal.swc" append="true"/>
> + </mxmlc>
> + </target>
> +
> +</project>
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/AntClasses.as
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/src/AntClasses.as b/ant_on_air/src/AntClasses.as
> new file mode 100644
> index 0000000..44a09c0
> --- /dev/null
> +++ b/ant_on_air/src/AntClasses.as
> @@ -0,0 +1,34 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package
> +{
> + public class AntClasses
> + {
> + public function AntClasses()
> + {
> + import org.apache.flex.ant.Ant; Ant;
> + import org.apache.flex.ant.tags.Project; Project;
> + import org.apache.flex.ant.tags.Condition; Condition;
> + import org.apache.flex.ant.tags.Echo; Echo;
> + import org.apache.flex.ant.tags.IsSet; IsSet;
> + import org.apache.flex.ant.tags.OS; OS;
> + import org.apache.flex.ant.tags.Property; Property;
> + }
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/ant/Ant.as
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/src/org/apache/flex/ant/Ant.as
> b/ant_on_air/src/org/apache/flex/ant/Ant.as
> new file mode 100644
> index 0000000..b81d8b6
> --- /dev/null
> +++ b/ant_on_air/src/org/apache/flex/ant/Ant.as
> @@ -0,0 +1,129 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.ant
> +{
> +
> + import flash.filesystem.File;
> + import flash.filesystem.FileMode;
> + import flash.filesystem.FileStream;
> +
> + import org.apache.flex.ant.tags.Project;
> + import org.apache.flex.xml.XMLTagProcessor;
> +
> + /**
> + * An XMLTagProcessor that tries to emulate Apache Ant
> + */
> + public class Ant extends XMLTagProcessor
> + {
> + /**
> + * Constructor
> + */
> + public function Ant()
> + {
> + super();
> + }
> +
> + /**
> + * @private
> + * The file being processed. Used to determine basedir.
> + */
> + private var file:File;
> +
> + /**
> + * Open a file, read the XML and create ITagHandlers for every
> tag
> + * @param file File The file to open.
> + * @param context Object An object containing an optional
> targets property listing the targets to run.
> + */
> + public function processXMLFile(file:File, context:Object =
> null):void
> + {
> + this.file = file;
> + var fs:FileStream = new FileStream();
> + fs.open(file, FileMode.READ);
> + var s:String = fs.readUTFBytes(fs.bytesAvailable);
> + var xml:XML = XML(s);
> + fs.close();
> +
> + tagMap = antTagProcessors;
> + if (!context)
> + context = {};
> + var project:Project = processXMLTag(xml, context) as Project;
> + project.execute();
> + }
> +
> + /**
> + * The map of XML tags to classes
> + */
> + public static var antTagProcessors:Object = {};
> +
> + /**
> + * Adds a class to the map.
> + *
> + * @param tagQName String The QName.toString() of the tag
> + * @param processor Class The class that will process the tag.
> + */
> + public static function addTagProcessor(tagQName:String,
> processor:Class):void
> + {
> + antTagProcessors[tagQName] = processor;
> + }
> +
> + /**
> + * Does string replacements based on properties in the context
> object.
> + *
> + * @param input String The input string.
> + * @param context Object The object of property values.
> + * @return String The input string with replaced values.
> + */
> + public function getValue(input:String, context:Object):String
> + {
> + var i:int = input.indexOf("${");
> + while (i != -1)
> + {
> + if (i == 0 || (i > 0 && input.charAt(i - 1) != "$"))
> + {
> + var c:int = input.indexOf("}", i);
> + if (c != -1)
> + {
> + var token:String = input.substring(i + 2, c);
> + if (context.hasOwnProperty(token))
> + {
> + var rep:String = context[token];
> + input = input.replace("${" + token + "}",
> rep);
> + i += rep.length - token.length - 3;
> + }
> + else if (token == "basedir")
> + {
> + var basedir:String = context.project.basedir;
> + rep =
> file.parent.resolvePath(basedir).nativePath;
> + input = input.replace("${" + token + "}",
> rep);
> + i += rep.length - token.length - 3;
> + }
> + }
> + }
> + i++;
> + i = input.indexOf("${", i);
> + }
> + return input;
> + }
> +
> + /**
> + * Output for Echo. Defaults to trace().
> + */
> + public var output:Function = function(s:String):void { trace(s) };
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/ant/tags/Condition.as
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Condition.as
> b/ant_on_air/src/org/apache/flex/ant/tags/Condition.as
> new file mode 100644
> index 0000000..87df06d
> --- /dev/null
> +++ b/ant_on_air/src/org/apache/flex/ant/tags/Condition.as
> @@ -0,0 +1,75 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.ant.tags
> +{
> + import mx.core.IFlexModuleFactory;
> +
> + import org.apache.flex.ant.Ant;
> + import org.apache.flex.ant.tags.supportClasses.IValueTagHandler;
> + import org.apache.flex.ant.tags.supportClasses.ParentTagHandler;
> + import org.apache.flex.xml.XMLTagProcessor;
> +
> + [Mixin]
> +
> + public class Condition extends ParentTagHandler
> + {
> + public static function init(mf:IFlexModuleFactory):void
> + {
> + Ant.antTagProcessors["condition"] = Condition;
> + }
> +
> + public function Condition()
> + {
> + super();
> + }
> +
> + override public function init(xml:XML, context:Object,
> xmlProcessor:XMLTagProcessor):void
> + {
> + // process attributes
> + super.init(xml, context, xmlProcessor);
> + // create child nodes
> + ant.processChildren(xml, context, this);
> + // if the property is not already set
> + if (_property && _value != null &&
> !context.hasOwnProperty(_property))
> + {
> + // get the value from the children
> + var val:Object = IValueTagHandler(getChildAt(0)).value;
> + if (val == "true" || val == true)
> + {
> + // set it if we should
> + if (_value != null)
> + val = _value;
> + context[_property] = val;
> + }
> + }
> + }
> +
> + private var _property:String;
> + private var _value:Object;
> +
> + override protected function processAttribute(name:String,
> value:String):void
> + {
> + if (name == "property")
> + _property = value;
> + else if (name == "value")
> + _value = value;
> + }
> +
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/ant/tags/Echo.as
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Echo.as
> b/ant_on_air/src/org/apache/flex/ant/tags/Echo.as
> new file mode 100644
> index 0000000..fa43d73
> --- /dev/null
> +++ b/ant_on_air/src/org/apache/flex/ant/tags/Echo.as
> @@ -0,0 +1,61 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.ant.tags
> +{
> + import mx.core.IFlexModuleFactory;
> +
> + import org.apache.flex.ant.Ant;
> + import org.apache.flex.ant.tags.supportClasses.TaskHandler;
> + import org.apache.flex.xml.ITextTagHandler;
> +
> + [Mixin]
> + public class Echo extends TaskHandler implements ITextTagHandler
> + {
> + public static function init(mf:IFlexModuleFactory):void
> + {
> + Ant.antTagProcessors["echo"] = Echo;
> + }
> +
> + public function Echo()
> + {
> + super();
> + }
> +
> + private var text:String;
> +
> + public function setText(text:String):void
> + {
> + this.text = text;
> + }
> +
> + override protected function processAttribute(name:String,
> value:String):void
> + {
> + if (name == "message")
> + text = value;
> + else
> + super.processAttribute(name, value);
> + }
> +
> + override public function execute():void
> + {
> + super.execute();
> + ant.output(ant.getValue(text, context));
> + }
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/ant/tags/IsSet.as
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/src/org/apache/flex/ant/tags/IsSet.as
> b/ant_on_air/src/org/apache/flex/ant/tags/IsSet.as
> new file mode 100644
> index 0000000..3ea565d
> --- /dev/null
> +++ b/ant_on_air/src/org/apache/flex/ant/tags/IsSet.as
> @@ -0,0 +1,56 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.ant.tags
> +{
> + import mx.core.IFlexModuleFactory;
> +
> + import org.apache.flex.ant.Ant;
> + import org.apache.flex.ant.tags.supportClasses.IValueTagHandler;
> + import org.apache.flex.ant.tags.supportClasses.TagHandler;
> +
> + [Mixin]
> + public class IsSet extends TagHandler implements IValueTagHandler
> + {
> + public static function init(mf:IFlexModuleFactory):void
> + {
> + Ant.antTagProcessors["isset"] = IsSet;
> + }
> +
> + public function IsSet()
> + {
> + super();
> + }
> +
> + private var _property:String;
> +
> + public function get value():Object
> + {
> + if (_property == null) return false;
> +
> + return context.hasOwnProperty(_property);
> + }
> +
> + override protected function processAttribute(name:String,
> value:String):void
> + {
> + if (name == "property")
> + _property = value;
> + }
> +
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/ant/tags/OS.as
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/src/org/apache/flex/ant/tags/OS.as
> b/ant_on_air/src/org/apache/flex/ant/tags/OS.as
> new file mode 100644
> index 0000000..cc81459
> --- /dev/null
> +++ b/ant_on_air/src/org/apache/flex/ant/tags/OS.as
> @@ -0,0 +1,58 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.ant.tags
> +{
> + import flash.system.Capabilities;
> +
> + import mx.core.IFlexModuleFactory;
> +
> + import org.apache.flex.ant.Ant;
> + import org.apache.flex.ant.tags.supportClasses.IValueTagHandler;
> + import org.apache.flex.ant.tags.supportClasses.TagHandler;
> +
> + [Mixin]
> + public class OS extends TagHandler implements IValueTagHandler
> + {
> + public static function init(mf:IFlexModuleFactory):void
> + {
> + Ant.antTagProcessors["os"] = OS;
> + }
> +
> + public function OS()
> + {
> + super();
> + }
> +
> + private var _family:String;
> +
> + public function get value():Object
> + {
> + if (_family == null) return false;
> +
> + return
> Capabilities.os.toLowerCase().indexOf(_family.toLowerCase()) != -1;
> + }
> +
> + override protected function processAttribute(name:String,
> value:String):void
> + {
> + if (name == "family")
> + _family = value;
> + }
> +
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/ant/tags/Project.as
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Project.as
> b/ant_on_air/src/org/apache/flex/ant/tags/Project.as
> new file mode 100644
> index 0000000..368f335
> --- /dev/null
> +++ b/ant_on_air/src/org/apache/flex/ant/tags/Project.as
> @@ -0,0 +1,111 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.ant.tags
> +{
> + import mx.core.IFlexModuleFactory;
> + import mx.utils.StringUtil;
> +
> + import org.apache.flex.ant.Ant;
> + import org.apache.flex.ant.tags.supportClasses.TaskHandler;
> + import org.apache.flex.xml.ITagHandler;
> + import org.apache.flex.xml.XMLTagProcessor;
> +
> + [Mixin]
> + public class Project extends TaskHandler
> + {
> + public static function init(mf:IFlexModuleFactory):void
> + {
> + Ant.antTagProcessors["project"] = Project;
> + }
> +
> + public function Project()
> + {
> + }
> +
> + override public function init(xml:XML, context:Object,
> xmlProcessor:XMLTagProcessor):void
> + {
> + context.project = this;
> + super.init(xml, context, xmlProcessor);
> + ant.processChildren(xml, context, this);
> + }
> +
> + private var _basedir:String;
> +
> + public function get basedir():String
> + {
> + return _basedir;
> + }
> +
> + private var _defaultTarget:String;
> +
> + public function get defaultTarget():String
> + {
> + return _defaultTarget;
> + }
> +
> + override protected function processAttribute(name:String,
> value:String):void
> + {
> + if (name == "basedir")
> + _basedir = value;
> + else if (name == "default")
> + _defaultTarget = value;
> + else
> + super.processAttribute(name, value);
> + }
> +
> + override public function execute():void
> + {
> + if (context.target == null)
> + context.target == _defaultTarget;
> +
> + var targets:Array;
> + var targetList:String = context.targets;
> + if (targetList.indexOf(',') != -1)
> + targets = targetList.split(",");
> + else
> + targets = [ targetList ];
> +
> + for each (var target:String in targets)
> + executeTarget(target);
> + }
> +
> + public function executeTarget(targetName:String):void
> + {
> + targetName = StringUtil.trim(targetName);
> + var n:int = numChildren;
> + for (var i:int = 0; i < n; i++)
> + {
> + var child:ITagHandler = getChildAt(i);
> + if (child is Target)
> + {
> + var t:Target = child as Target;
> + if (t.name == targetName)
> + {
> + t.execute();
> + return;
> + }
> + }
> + }
> +
> + trace("missing target: ", targetName);
> + throw new Error("missing target: " + targetName);
> +
> + }
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/ant/tags/Property.as
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Property.as
> b/ant_on_air/src/org/apache/flex/ant/tags/Property.as
> new file mode 100644
> index 0000000..60bd6f8
> --- /dev/null
> +++ b/ant_on_air/src/org/apache/flex/ant/tags/Property.as
> @@ -0,0 +1,99 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.ant.tags
> +{
> + import flash.filesystem.File;
> + import flash.filesystem.FileMode;
> + import flash.filesystem.FileStream;
> +
> + import mx.core.IFlexModuleFactory;
> + import mx.utils.StringUtil;
> +
> + import org.apache.flex.ant.Ant;
> + import org.apache.flex.ant.tags.supportClasses.NamedTagHandler;
> + import org.apache.flex.xml.XMLTagProcessor;
> +
> + [Mixin]
> + public class Property extends NamedTagHandler
> + {
> + public static function init(mf:IFlexModuleFactory):void
> + {
> + Ant.antTagProcessors["property"] = Property;
> + }
> +
> + public function Property()
> + {
> + }
> +
> + override public function init(xml:XML, context:Object,
> xmlProcessor:XMLTagProcessor):void
> + {
> + super.init(xml, context, xmlProcessor);
> + if (name && value && !context.hasOwnProperty(name))
> + context[name] = value;
> + }
> +
> + private var fileName:String;
> + private var value:String;
> + private var envPrefix:String;
> +
> + override protected function processAttribute(name:String,
> value:String):void
> + {
> + if (name == "file")
> + {
> + fileName = ant.getValue(value, context);
> + var f:File = new File(fileName);
> + var fs:FileStream = new FileStream();
> + fs.open(f, FileMode.READ);
> + var data:String = fs.readUTFBytes(fs.bytesAvailable);
> + var propLines:Array = data.split("\n");
> + for each (var line:String in propLines)
> + {
> + var parts:Array = line.split("=");
> + if (parts.length >= 2)
> + {
> + var key:String = StringUtil.trim(parts[0]);
> + var val:String;
> + if (parts.length == 2)
> + val = parts[1];
> + else
> + {
> + parts.shift();
> + val = parts.joint("=");
> + }
> + context[key] = val;
> + }
> +
> + }
> + fs.close();
> + }
> + else if (name == "value")
> + {
> + this.value = ant.getValue(value, context);
> + }
> + else if (name == "environment")
> + {
> + envPrefix = value;
> + // TODO
> + ant.output("environment attribute is not supported");
> + }
> + else
> + super.processAttribute(name, value);
> + }
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/ant/tags/Target.as
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Target.as
> b/ant_on_air/src/org/apache/flex/ant/tags/Target.as
> new file mode 100644
> index 0000000..146942f
> --- /dev/null
> +++ b/ant_on_air/src/org/apache/flex/ant/tags/Target.as
> @@ -0,0 +1,97 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.ant.tags
> +{
> + import mx.core.IFlexModuleFactory;
> +
> + import org.apache.flex.ant.Ant;
> + import org.apache.flex.ant.tags.supportClasses.TaskHandler;
> + import org.apache.flex.xml.XMLTagProcessor;
> +
> + [Mixin]
> + public class Target extends TaskHandler
> + {
> + public static function init(mf:IFlexModuleFactory):void
> + {
> + Ant.antTagProcessors["target"] = Target;
> + }
> +
> + public function Target()
> + {
> + }
> +
> + override public function init(xml:XML, context:Object,
> xmlProcessor:XMLTagProcessor):void
> + {
> + this.xml = xml;
> + project = context.project as Project;
> + super.init(xml, context, xmlProcessor);
> + }
> +
> + private var project:Project;
> +
> + private var _depends:String;
> +
> + public function get depends():String
> + {
> + return _depends;
> + }
> +
> + override protected function processAttribute(name:String,
> value:String):void
> + {
> + if (name == "depends")
> + _depends = value;
> + else
> + super.processAttribute(name, value);
> + }
> +
> + override protected function processAttributes(xmlList:XMLList,
> context:Object):void
> + {
> + super.processAttributes(xmlList, context);
> + context.currentTarget = this;
> + }
> +
> + private function processDepends():void
> + {
> + if (!_depends)
> + return;
> +
> + var dependsList:Array = _depends.split(",");
> + for each (var d:String in dependsList)
> + project.executeTarget(d);
> + }
> +
> + override public function execute():void
> + {
> + processDepends();
> + ant.processChildren(xml, context, this);
> + processSteps();
> + }
> +
> + private function processSteps():void
> + {
> + var n:int = numChildren;
> + for (var i:int = 0; i < n; i++)
> + {
> + var step:TaskHandler = getChildAt(i) as TaskHandler;
> + step.execute();
> + }
> + }
> +
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/IValueTagHandler.as
> ----------------------------------------------------------------------
> diff --git
> a/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/IValueTagHandler.as
> b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/IValueTagHandler.as
> new file mode 100644
> index 0000000..cc202b5
> --- /dev/null
> +++
> b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/IValueTagHandler.as
> @@ -0,0 +1,30 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.ant.tags.supportClasses
> +{
> + import org.apache.flex.xml.ITagHandler;
> +
> + /**
> + * The interface for ITagHandlers that return a value
> + */
> + public interface IValueTagHandler extends ITagHandler
> + {
> + function get value():Object;
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/NamedTagHandler.as
> ----------------------------------------------------------------------
> diff --git
> a/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/NamedTagHandler.as
> b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/NamedTagHandler.as
> new file mode 100644
> index 0000000..bfe3f6e
> --- /dev/null
> +++
> b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/NamedTagHandler.as
> @@ -0,0 +1,50 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.ant.tags.supportClasses
> +{
> + /**
> + * Base class for ITagHandlers that have a name attribute.
> + */
> + public class NamedTagHandler extends ParentTagHandler
> + {
> + public function NamedTagHandler()
> + {
> + }
> +
> + private var _name:String;
> +
> + /**
> + * The name property.
> + */
> + public function get name():String
> + {
> + return _name;
> + }
> +
> + /**
> + * @private
> + */
> + override protected function processAttribute(name:String,
> value:String):void
> + {
> + if (name == "name")
> + _name = value;
> + }
> +
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/ParentTagHandler.as
> ----------------------------------------------------------------------
> diff --git
> a/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/ParentTagHandler.as
> b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/ParentTagHandler.as
> new file mode 100644
> index 0000000..f6c2941
> --- /dev/null
> +++
> b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/ParentTagHandler.as
> @@ -0,0 +1,50 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.ant.tags.supportClasses
> +{
> + import org.apache.flex.xml.IParentTagHandler;
> + import org.apache.flex.xml.ITagHandler;
> +
> + /**
> + * The base class for ITagHandlers that have children
> + */
> + public class ParentTagHandler extends TagHandler implements
> IParentTagHandler
> + {
> + private var children:Array;
> +
> + public function addChild(child:ITagHandler):ITagHandler
> + {
> + if (children == null)
> + children = [ child ];
> + else
> + children.push(child);
> + return child;
> + }
> +
> + public function getChildAt(index:int):ITagHandler
> + {
> + return children[index];
> + }
> +
> + public function get numChildren():int
> + {
> + return children.length;
> + }
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TagHandler.as
> ----------------------------------------------------------------------
> diff --git
> a/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TagHandler.as
> b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TagHandler.as
> new file mode 100644
> index 0000000..28db76f
> --- /dev/null
> +++ b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TagHandler.as
> @@ -0,0 +1,84 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.ant.tags.supportClasses
> +{
> + import org.apache.flex.xml.XMLTagProcessor;
> + import org.apache.flex.ant.Ant;
> + import org.apache.flex.xml.ITagHandler;
> +
> + /**
> + * The lowest-level base class for ITagHandlers for Ant.
> + */
> + public class TagHandler implements ITagHandler
> + {
> + /**
> + * Constructor
> + */
> + public function TagHandler()
> + {
> + }
> +
> + /**
> + * The Ant instance. Often used for getValue() and output()
> methods.
> + */
> + protected var ant:Ant;
> +
> + /**
> + * The context object. Contains a project property referencing
> the project.
> + */
> + protected var context:Object;
> +
> + /**
> + * The xml node for this tag
> + */
> + protected var xml:XML;
> +
> + /**
> + * @see org.apache.flex.xml.ITagHandler
> + */
> + public function init(xml:XML, context:Object,
> xmlProcessor:XMLTagProcessor):void
> + {
> + ant = xmlProcessor as Ant;
> + this.context = context;
> + this.xml = xml;
> + processAttributes(xml.attributes(), context);
> + }
> +
> + /**
> + * Loop through and process attributes.
> + * @param xmlList XMLList The list of attributes.
> + * @param context Object An object containing useful information.
> + */
> + protected function processAttributes(xmlList:XMLList,
> context:Object):void
> + {
> + var n:int = xmlList.length();
> + for (var i:int = 0; i < n; i++)
> + processAttribute(xmlList[i].name().toString(),
> xmlList[i].toString());
> + }
> +
> + /**
> + * Process an attribute on the tag.
> + * @param name String The attribute name.
> + * @param value String The attribute value.
> + */
> + protected function processAttribute(name:String,
> value:String):void
> + {
> + }
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TaskHandler.as
> ----------------------------------------------------------------------
> diff --git
> a/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TaskHandler.as
> b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TaskHandler.as
> new file mode 100644
> index 0000000..6ddccfb
> --- /dev/null
> +++ b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TaskHandler.as
> @@ -0,0 +1,42 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.ant.tags.supportClasses
> +{
> +
> + /**
> + * The base class for ITagHandlers that do work
> + */
> + public class TaskHandler extends NamedTagHandler
> + {
> + public function TaskHandler()
> + {
> + }
> +
> + /**
> + * Do the work.
> + * TaskHandlers lazily create their children so
> + * super.execute() should be called before
> + * doing any real work.
> + */
> + public function execute():void
> + {
> + ant.processChildren(this.xml, context, this);
> + }
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/xml/IParentTagHandler.as
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/src/org/apache/flex/xml/IParentTagHandler.as
> b/ant_on_air/src/org/apache/flex/xml/IParentTagHandler.as
> new file mode 100644
> index 0000000..cd8209f
> --- /dev/null
> +++ b/ant_on_air/src/org/apache/flex/xml/IParentTagHandler.as
> @@ -0,0 +1,46 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.xml
> +{
> + /**
> + * The interface for ITagHandlers that can have children
> + */
> + public interface IParentTagHandler extends ITagHandler
> + {
> + /**
> + * Add a child ITagHandler
> + * @param child ITagHandler The child.
> + * @return ITagHandler The child.
> + */
> + function addChild(child:ITagHandler):ITagHandler;
> +
> + /**
> + * Get a child ITagHandler
> + * @param index int The index of the child.
> + * @return ITagHandler The child.
> + */
> + function getChildAt(index:int):ITagHandler;
> +
> + /**
> + * The number of children.
> + * @return int The number of children.
> + */
> + function get numChildren():int;
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/xml/ITagHandler.as
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/src/org/apache/flex/xml/ITagHandler.as
> b/ant_on_air/src/org/apache/flex/xml/ITagHandler.as
> new file mode 100644
> index 0000000..36fde54
> --- /dev/null
> +++ b/ant_on_air/src/org/apache/flex/xml/ITagHandler.as
> @@ -0,0 +1,34 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.xml
> +{
> + /**
> + * The interface for all classes that represeting XML tags
> + */
> + public interface ITagHandler
> + {
> + /**
> + * This method is called after the instance is created
> + * @param xml XML The XML node.
> + * @param context Object An object containing useful information.
> + * @param tagProcessor The XMLTagProcessor that generated this
> instance.
> + */
> + function init(xml:XML, context:Object,
> tagProcessor:XMLTagProcessor):void;
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/xml/ITextTagHandler.as
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/src/org/apache/flex/xml/ITextTagHandler.as
> b/ant_on_air/src/org/apache/flex/xml/ITextTagHandler.as
> new file mode 100644
> index 0000000..e14bdcb
> --- /dev/null
> +++ b/ant_on_air/src/org/apache/flex/xml/ITextTagHandler.as
> @@ -0,0 +1,29 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.xml
> +{
> + /**
> + * Interface for ITagHanders that can handle text nodes such as
> + * <echo>This is a message</echo>
> + */
> + public interface ITextTagHandler extends ITagHandler
> + {
> + function setText(text:String):void;
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/src/org/apache/flex/xml/XMLTagProcessor.as
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/src/org/apache/flex/xml/XMLTagProcessor.as
> b/ant_on_air/src/org/apache/flex/xml/XMLTagProcessor.as
> new file mode 100644
> index 0000000..fc7bdfd
> --- /dev/null
> +++ b/ant_on_air/src/org/apache/flex/xml/XMLTagProcessor.as
> @@ -0,0 +1,82 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package org.apache.flex.xml
> +{
> + /**
> + * Base class for processing XML Tags
> + */
> + public class XMLTagProcessor
> + {
> + /**
> + * Constructor
> + */
> + public function XMLTagProcessor()
> + {
> + }
> +
> + /**
> + * Find the associated class for the XML tag and generate
> + * and instance of it.
> + *
> + * @param xml XML The XML node.
> + * @param context Object An object containing useful information.
> + * @return ITagHandler An instance representing this XML node
> + */
> + public function processXMLTag(xml:XML, context:Object):ITagHandler
> + {
> + var tag:String = xml.name().toString();
> + var c:Class = tagMap[tag];
> + if (!c)
> + {
> + trace("no processor for ", tag);
> + throw new Error("no processor for " + tag);
> + }
> + var o:ITagHandler = new c() as ITagHandler;
> + o.init(xml, context, this);
> + return o;
> + }
> +
> + /**
> + * Loop through the children of a node and process them
> + *
> + * @param xml XML The XML node.
> + * @param context Object An object containing useful information.
> + * @param parentTag IParentTagHandler The parent for the
> instances that are created.
> + */
> + public function processChildren(xml:XML, context:Object,
> parentTag:IParentTagHandler):void
> + {
> + var xmlList:XMLList = xml.children();
> + var n:int = xmlList.length();
> + for (var i:int = 0; i < n; i++)
> + {
> + var kind:String = xmlList[i].nodeKind();
> + if (kind == "text")
> +
> ITextTagHandler(parentTag).setText(xmlList[i].toString());
> + else
> + {
> + var tagHandler:ITagHandler =
> processXMLTag(xmlList[i], context);
> + parentTag.addChild(tagHandler);
> + }
> + }
> + }
> +
> + public var tagMap:Object = {};
> +
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/tests/TestTarget-app.xml
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/tests/TestTarget-app.xml
> b/ant_on_air/tests/TestTarget-app.xml
> new file mode 100644
> index 0000000..5b823a8
> --- /dev/null
> +++ b/ant_on_air/tests/TestTarget-app.xml
> @@ -0,0 +1,250 @@
> +<?xml version="1.0" encoding="utf-8" standalone="no"?>
> +<!--
> +
> + Licensed to the Apache Software Foundation (ASF) under one or more
> + contributor license agreements. See the NOTICE file distributed with
> + this work for additional information regarding copyright ownership.
> + The ASF licenses this file to You under the Apache License, Version 2.0
> + (the "License"); you may not use this file except in compliance with
> + the License. You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing, software
> + distributed under the License is distributed on an "AS IS" BASIS,
> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + See the License for the specific language governing permissions and
> + limitations under the License.
> +
> +-->
> +<application xmlns="http://ns.adobe.com/air/application/3.4">
> +
> +<!-- Adobe AIR Application Descriptor File Template.
> +
> + Specifies parameters for identifying, installing, and launching
> AIR applications.
> +
> + xmlns - The Adobe AIR namespace:
> http://ns.adobe.com/air/application/3.1
> + The last segment of the namespace specifies the
> version
> + of the AIR runtime required for this application
> to run.
> +
> + minimumPatchLevel - The minimum patch level of the AIR runtime
> required to run
> + the application. Optional.
> +-->
> +
> + <!-- A universally unique application identifier. Must be unique
> across all AIR applications.
> + Using a reverse DNS-style name as the id is recommended. (Eg.
> com.example.ExampleApplication.) Required. -->
> + <id>TestTarget</id>
> +
> + <!-- Used as the filename for the application. Required. -->
> + <filename>TestTarget</filename>
> +
> + <!-- The name that is displayed in the AIR application installer.
> + May have multiple values for each language. See samples or xsd
> schema file. Optional. -->
> + <name>TestTarget</name>
> +
> + <!-- A string value of the format <0-999>.<0-999>.<0-999> that
> represents application version which can be used to check for application
> upgrade.
> + Values can also be 1-part or 2-part. It is not necessary to have a
> 3-part value.
> + An updated version of application must have a versionNumber value
> higher than the previous version. Required for namespace >= 2.5 . -->
> + <versionNumber>0.0.0</versionNumber>
> +
> + <!-- A string value (such as "v1", "2.5", or "Alpha 1") that
> represents the version of the application, as it should be shown to users.
> Optional. -->
> + <!-- <versionLabel></versionLabel> -->
> +
> + <!-- Description, displayed in the AIR application installer.
> + May have multiple values for each language. See samples or xsd
> schema file. Optional. -->
> + <!-- <description></description> -->
> +
> + <!-- Copyright information. Optional -->
> + <!-- <copyright></copyright> -->
> +
> + <!-- Publisher ID. Used if you're updating an application created
> prior to 1.5.3 -->
> + <!-- <publisherID></publisherID> -->
> +
> + <!-- Settings for the application's initial window. Required. -->
> + <initialWindow>
> + <!-- The main SWF or HTML file of the application.
> Required. -->
> + <!-- Note: In Flash Builder, the SWF reference is set
> automatically. -->
> + <content>TestTarget.swf</content>
> +
> + <!-- The title of the main window. Optional. -->
> + <!-- <title></title> -->
> +
> + <!-- The type of system chrome to use (either "standard"
> or "none"). Optional. Default standard. -->
> + <!-- <systemChrome></systemChrome> -->
> +
> + <!-- Whether the window is transparent. Only applicable
> when systemChrome is none. Optional. Default false. -->
> + <!-- <transparent></transparent> -->
> +
> + <!-- Whether the window is initially visible. Optional.
> Default false. -->
> + <!-- <visible></visible> -->
> +
> + <!-- Whether the user can minimize the window. Optional.
> Default true. -->
> + <!-- <minimizable></minimizable> -->
> +
> + <!-- Whether the user can maximize the window. Optional.
> Default true. -->
> + <!-- <maximizable></maximizable> -->
> +
> + <!-- Whether the user can resize the window. Optional.
> Default true. -->
> + <!-- <resizable></resizable> -->
> +
> + <!-- The window's initial width in pixels. Optional. -->
> + <!-- <width></width> -->
> +
> + <!-- The window's initial height in pixels. Optional. -->
> + <!-- <height></height> -->
> +
> + <!-- The window's initial x position. Optional. -->
> + <!-- <x></x> -->
> +
> + <!-- The window's initial y position. Optional. -->
> + <!-- <y></y> -->
> +
> + <!-- The window's minimum size, specified as a
> width/height pair in pixels, such as "400 200". Optional. -->
> + <!-- <minSize></minSize> -->
> +
> + <!-- The window's initial maximum size, specified as a
> width/height pair in pixels, such as "1600 1200". Optional. -->
> + <!-- <maxSize></maxSize> -->
> +
> + <!-- The initial aspect ratio of the app when launched (either
> "portrait" or "landscape"). Optional. Mobile only. Default is the natural
> orientation of the device -->
> +
> + <!-- <aspectRatio></aspectRatio> -->
> +
> + <!-- Whether the app will begin auto-orienting on launch.
> Optional. Mobile only. Default false -->
> +
> + <!-- <autoOrients></autoOrients> -->
> +
> + <!-- Whether the app launches in full screen. Optional. Mobile
> only. Default false -->
> +
> + <!-- <fullScreen></fullScreen> -->
> +
> + <!-- The render mode for the app (either auto, cpu, gpu, or
> direct). Optional. Default auto -->
> +
> + <!-- <renderMode></renderMode> -->
> +
> + <!-- Whether or not to pan when a soft keyboard is raised
> or lowered (either "pan" or "none"). Optional. Defaults "pan." -->
> + <!-- <softKeyboardBehavior></softKeyboardBehavior> -->
> + <autoOrients>false</autoOrients>
> + <fullScreen>false</fullScreen>
> + <visible>false</visible>
> + </initialWindow>
> +
> + <!-- We recommend omitting the supportedProfiles element, -->
> + <!-- which in turn permits your application to be deployed to all
> -->
> + <!-- devices supported by AIR. If you wish to restrict deployment
> -->
> + <!-- (i.e., to only mobile devices) then add this element and list
> -->
> + <!-- only the profiles which your application does support. -->
> + <!-- <supportedProfiles>desktop extendedDesktop mobileDevice
> extendedMobileDevice</supportedProfiles> -->
> +
> + <!-- The subpath of the standard default installation location to
> use. Optional. -->
> + <!-- <installFolder></installFolder> -->
> +
> + <!-- The subpath of the Programs menu to use. (Ignored on
> operating systems without a Programs menu.) Optional. -->
> + <!-- <programMenuFolder></programMenuFolder> -->
> +
> + <!-- The icon the system uses for the application. For at least
> one resolution,
> + specify the path to a PNG file included in the AIR package.
> Optional. -->
> + <!-- <icon>
> + <image16x16></image16x16>
> + <image32x32></image32x32>
> + <image36x36></image36x36>
> + <image48x48></image48x48>
> + <image57x57></image57x57>
> + <image72x72></image72x72>
> + <image114x114></image114x114>
> + <image128x128></image128x128>
> + </icon> -->
> +
> + <!-- Whether the application handles the update when a user
> double-clicks an update version
> + of the AIR file (true), or the default AIR application installer
> handles the update (false).
> + Optional. Default false. -->
> + <!-- <customUpdateUI></customUpdateUI> -->
> +
> + <!-- Whether the application can be launched when the user clicks
> a link in a web browser.
> + Optional. Default false. -->
> + <!-- <allowBrowserInvocation></allowBrowserInvocation> -->
> +
> + <!-- Listing of file types for which the application can register.
> Optional. -->
> + <!-- <fileTypes> -->
> +
> + <!-- Defines one file type. Optional. -->
> + <!-- <fileType> -->
> +
> + <!-- The name that the system displays for the
> registered file type. Required. -->
> + <!-- <name></name> -->
> +
> + <!-- The extension to register. Required. -->
> + <!-- <extension></extension> -->
> +
> + <!-- The description of the file type. Optional.
> -->
> + <!-- <description></description> -->
> +
> + <!-- The MIME content type. -->
> + <!-- <contentType></contentType> -->
> +
> + <!-- The icon to display for the file type.
> Optional. -->
> + <!-- <icon>
> + <image16x16></image16x16>
> + <image32x32></image32x32>
> + <image48x48></image48x48>
> + <image128x128></image128x128>
> + </icon> -->
> +
> + <!-- </fileType> -->
> + <!-- </fileTypes> -->
> +
> + <!-- iOS specific capabilities -->
> + <!-- <iPhone> -->
> + <!-- A list of plist key/value pairs to be added to the
> application Info.plist -->
> + <!-- <InfoAdditions>
> + <![CDATA[
> + <key>UIDeviceFamily</key>
> + <array>
> + <string>1</string>
> + <string>2</string>
> + </array>
> + <key>UIStatusBarStyle</key>
> + <string>UIStatusBarStyleBlackOpaque</string>
> + <key>UIRequiresPersistentWiFi</key>
> + <string>YES</string>
> + ]]>
> + </InfoAdditions> -->
> + <!-- A list of plist key/value pairs to be added to the
> application Entitlements.plist -->
> + <!-- <Entitlements>
> + <![CDATA[
> + <key>keychain-access-groups</key>
> + <array>
> + <string></string>
> + <string></string>
> + </array>
> + ]]>
> + </Entitlements> -->
> + <!-- Display Resolution for the app (either "standard" or "high").
> Optional. Default "standard" -->
> + <!-- <requestedDisplayResolution></requestedDisplayResolution> -->
> + <!-- </iPhone> -->
> +
> + <!-- Specify Android specific tags that get passed to
> AndroidManifest.xml file. -->
> + <!--<android> -->
> + <!-- <manifestAdditions>
> + <![CDATA[
> + <manifest android:installLocation="auto">
> + <uses-permission
> android:name="android.permission.INTERNET"/>
> + <uses-permission
> android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
> + <uses-permission
> android:name="android.permission.ACCESS_FINE_LOCATION"/>
> + <uses-feature android:required="true"
> android:name="android.hardware.touchscreen.multitouch"/>
> + <application android:enabled="true">
> + <activity
> android:excludeFromRecents="false">
> + <intent-filter>
> + <action
> android:name="android.intent.action.MAIN"/>
> + <category
> android:name="android.intent.category.LAUNCHER"/>
> + </intent-filter>
> + </activity>
> + </application>
> + </manifest>
> + ]]>
> + </manifestAdditions> -->
> + <!-- Color depth for the app (either "32bit" or "16bit").
> Optional. Default 16bit before namespace 3.0, 32bit after -->
> + <!-- <colorDepth></colorDepth> -->
> + <!-- </android> -->
> + <!-- End of the schema for adding the android specific tags in
> AndroidManifest.xml file -->
> +
> +</application>
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/tests/TestTarget.as
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/tests/TestTarget.as
> b/ant_on_air/tests/TestTarget.as
> new file mode 100644
> index 0000000..0f7db80
> --- /dev/null
> +++ b/ant_on_air/tests/TestTarget.as
> @@ -0,0 +1,47 @@
>
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
>
> +////////////////////////////////////////////////////////////////////////////////
> +package
> +{
> + import flash.desktop.NativeApplication;
> + import flash.display.Sprite;
> + import flash.filesystem.File;
> + import org.apache.flex.ant.Ant;
> + import org.apache.flex.ant.tags.Condition; Condition.init(null);
> + import org.apache.flex.ant.tags.Echo; Echo.init(null);
> + import org.apache.flex.ant.tags.IsSet; IsSet.init(null);
> + import org.apache.flex.ant.tags.OS; OS.init(null);
> + import org.apache.flex.ant.tags.Project; Project.init(null);
> + import org.apache.flex.ant.tags.Property; Property.init(null);
> + import org.apache.flex.ant.tags.Target; Target.init(null);
> +
> + public class TestTarget extends Sprite
> + {
> + public function TestTarget()
> + {
> + ant = new Ant();
> + var context:Object = { targets: "test" };
> + var file:File = File.applicationDirectory;
> + file = file.resolvePath("test.xml");
> + ant.processXMLFile(file, context);
> + NativeApplication.nativeApplication.exit();
> + }
> +
> + private var ant:Ant;
> + }
> +}
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/322d1c56/ant_on_air/tests/test.xml
> ----------------------------------------------------------------------
> diff --git a/ant_on_air/tests/test.xml b/ant_on_air/tests/test.xml
> new file mode 100644
> index 0000000..5d55451
> --- /dev/null
> +++ b/ant_on_air/tests/test.xml
> @@ -0,0 +1,75 @@
> +<?xml version="1.0"?>
> +<!--
> +
> + Licensed to the Apache Software Foundation (ASF) under one or more
> + contributor license agreements. See the NOTICE file distributed with
> + this work for additional information regarding copyright ownership.
> + The ASF licenses this file to You under the Apache License, Version 2.0
> + (the "License"); you may not use this file except in compliance with
> + the License. You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing, software
> + distributed under the License is distributed on an "AS IS" BASIS,
> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + See the License for the specific language governing permissions and
> + limitations under the License.
> +
> +-->
> +
> +<project name="ant_on_air_test" basedir="." default="build">
> +
> + <!--load environment variables prefixed with env -->
> + <property environment="env"/>
> +
> + <!--location of property file -->
> + <property file="${basedir}/../build.properties"
> description="Properties for Ant On AIR project" />
> +
> + <!--
> + Properties are immutable so value frozen first time property is
> set.
> + If FLEX_HOME is not set with -DFLEX_HOME=/path/to/flex/sdk on the
> ant command line
> + use the environment variable, if it exists. Else if windows, use
> FLEX_HOME_WIN
> + else use FLEX_HOME_MAC, which are both defined in
> build.properties.
> + -->
> + <condition property="FLEX_HOME" value="${env.FLEX_HOME}">
> + <isset property="env.FLEX_HOME" />
> + </condition>
> +
> + <condition property="theOS" value="Windows">
> + <os family="windows"/>
> + </condition>
> + <condition property="theOS" value="Mac">
> + <os family="mac"/>
> + </condition>
> +
> + <target name="test">
> + <echo>FLEX_HOME is ${FLEX_HOME}. DEBUG is ${DEBUG_FLAG}.
> The OS is ${theOS}</echo>
> + </target>
> +
> + <target name="build" depends="init,compile"
> + description="Compiles SWC"/>
> +
> + <target name="init" depends="clean"
> + description="Creates the deploy folders and sets app extension"/>
> +
> + <target name="clean" description="Cleans up old files.">
> + <delete dir="${LIBRARY_DIR}" failOnError="false"
> includeEmptyDirs="true" />
> + </target>
> +
> + <target name="compile"
> + description="Compiles the SWC.">
> + <compc
> + output="${LIBRARY_DIR}/${LIBRARY_NAME}.swc"
> + debug="${DEBUG_FLAG}"
> + failonerror="true"
> + fork="true"
> + maxmemory="512m">
> + <source-path path-element="${SOURCE_DIR}"/>
> + <external-library-path
> file="${AIR_HOME}/frameworks/libs/air/airglobal.swc" append="true"/>
> + <include-classes>AntClasses</include-classes>
> +
> + </compc>
> + </target>
> +
> +</project>
>
>