flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [12/14] git commit: [flex-utilities] [refs/heads/develop] - get basic filesets to copy
Date Mon, 09 Dec 2013 23:30:14 GMT
get basic filesets to copy


Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/3a3f2326
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/3a3f2326
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/3a3f2326

Branch: refs/heads/develop
Commit: 3a3f2326070cadf1cd6b6c14f1a916d74b0ce9df
Parents: a4728f7
Author: Alex Harui <aharui@apache.org>
Authored: Mon Dec 9 14:01:53 2013 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Mon Dec 9 14:01:53 2013 -0800

----------------------------------------------------------------------
 ant_on_air/src/org/apache/flex/ant/tags/Copy.as | 36 +++++++--
 .../src/org/apache/flex/ant/tags/FileSet.as     |  1 +
 .../ant/tags/filesetClasses/DirectoryScanner.as | 77 ++++++++++----------
 .../flex/ant/tags/filesetClasses/FileUtils.as   |  8 +-
 .../ant/tags/filesetClasses/StringTokenizer.as  | 18 +++--
 .../tags/supportClasses/FileSetTaskHandler.as   |  5 +-
 ant_on_air/tests/TestTarget.as                  |  7 ++
 ant_on_air/tests/test.xml                       | 20 +++++
 8 files changed, 117 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/src/org/apache/flex/ant/tags/Copy.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Copy.as b/ant_on_air/src/org/apache/flex/ant/tags/Copy.as
index 4bdb0cc..3636ad0 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/Copy.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Copy.as
@@ -18,6 +18,8 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.ant.tags
 {
+    import flash.filesystem.File;
+    
     import mx.core.IFlexModuleFactory;
     
     import org.apache.flex.ant.Ant;
@@ -46,7 +48,7 @@ package org.apache.flex.ant.tags
             if (name == "file")
                 fileName = value;
             else if (name == "toFile")
-                toFileName == value;
+                toFileName = value;
             else if (name == "toDir")
                 toDirName = value;
             else if (name == "overwrite")
@@ -57,17 +59,37 @@ package org.apache.flex.ant.tags
 
         override protected function actOnFile(dir:String, fileName:String):void
         {
+            var srcName:String;
+            if (dir)
+                srcName = dir + File.separator + fileName;
+            else
+                srcName = fileName;
+            var srcFile:File = File.applicationDirectory.resolvePath(srcName);
             
+            var destName:String;
+            if (toDirName)
+                destName = toDirName + File.separator + fileName;
+            else
+                destName = toFileName;
+            var destFile:File = File.applicationDirectory.resolvePath(destName);
+                
+            srcFile.copyTo(destFile, overwrite);
         }
         
-        /**
-         *  Do the work.
-         *  TaskHandlers lazily create their children so
-         *  super.execute() should be called before
-         *  doing any real work. 
-         */
         override public function execute():Boolean
         {
+            var retVal:Boolean = super.execute();
+            if (numChildren > 0)
+                return retVal;
+            
+            var srcFile:File = File.applicationDirectory.resolvePath(fileName);
+            var destFile:File = File.applicationDirectory.resolvePath(toFileName);;
+            //var destDir:File = destFile.parent;
+            //var resolveName:String = destFile.nativePath.substr(destFile.nativePath.lastIndexOf(File.separator)
+ 1);
+            //destDir.resolvePath(resolveName);
+            
+            
+            srcFile.copyTo(destFile, overwrite);
             return true;
         }
     }

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/src/org/apache/flex/ant/tags/FileSet.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/FileSet.as b/ant_on_air/src/org/apache/flex/ant/tags/FileSet.as
index 4a01395..c6fb109 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/FileSet.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/FileSet.as
@@ -53,6 +53,7 @@ package org.apache.flex.ant.tags
         {
             if (_value) return _value;
             
+            ant.processChildren(xml, context, this);
             var ds:DirectoryScanner = new DirectoryScanner();
             var n:int = numChildren;
             var includes:Vector.<String> = new Vector.<String>();

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/DirectoryScanner.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/DirectoryScanner.as b/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/DirectoryScanner.as
index e6f1927..379bb6c 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/DirectoryScanner.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/DirectoryScanner.as
@@ -526,11 +526,14 @@ package org.apache.flex.ant.tags.filesetClasses
          * @since Ant 1.6
          */
         public static function resetDefaultExcludes():Vector.<String> {
-                defaultExcludes.length = 0;
+                var arr:Vector.<String> = defaultExcludes;
+                if (!arr)
+                    arr = new Vector.<String>();
+                arr.length = 0;
                 for (var i:int = 0; i < DEFAULTEXCLUDES.length; i++) {
-                    defaultExcludes.push(DEFAULTEXCLUDES[i]);
+                    arr.push(DEFAULTEXCLUDES[i]);
                 }
-                return defaultExcludes;
+                return arr;
         }
         
         /**
@@ -819,6 +822,8 @@ package org.apache.flex.ant.tags.filesetClasses
                     excludes = nullExcludes ? null : excludes;
             } catch (ex:IOException) {
                 throw new BuildException(ex.message);
+            } catch (e:Error) {
+                throw new BuildException(e.message);
             } finally {
                 basedir = savedBase;
             }
@@ -843,14 +848,14 @@ package org.apache.flex.ant.tags.filesetClasses
                         pattern;
                 }
             }
-            for each (var entry:Dictionary in includeNonPatterns.entrySet()) {
+            for each (var entry:Object in includeNonPatterns) {
                 for (var p:String in entry)
                 {
                     pattern = p;
                     break;
                 }
                 if (!shouldSkipPattern(pattern)) {
-                    newroots[entry.getValue()] = pattern;
+                    newroots[entry[pattern]] = pattern;
                 }
             }
             
@@ -870,13 +875,9 @@ package org.apache.flex.ant.tags.filesetClasses
                 }
                 // only scan directories that can include matched files or
                 // directories
-                for each (entry in newroots.entrySet()) {
+                for (entry in newroots) {
                     var currentPath:TokenizedPath;
-                    for (p in entry)
-                    {
-                        currentPath = p as TokenizedPath;
-                        break;
-                    }
+                    currentPath = entry as TokenizedPath;
                     var currentelement:String = currentPath.toString();
                     if (basedir == null
                         && !FileUtils.isAbsolutePath(currentelement)) {
@@ -895,7 +896,7 @@ package org.apache.flex.ant.tags.filesetClasses
                                 ? myCanonFile.nativePath
                                 : FILE_UTILS.removeLeadingPath(canonBase,
                                     myCanonFile);
-                            if (!path == currentelement) {
+                            if (path != currentelement) {
                                 myfile = currentPath.findFile(basedir, true);
                                 if (myfile != null && basedir != null) {
                                     currentelement = FILE_UTILS.removeLeadingPath(
@@ -941,10 +942,7 @@ package org.apache.flex.ant.tags.filesetClasses
                             }
                         } else {
                             var originalpattern:String;
-                            for (var q:* in entry)
-                            {
-                                originalpattern = entry[q];
-                            }
+                                originalpattern = newroots[entry] as String;
                             var included:Boolean = isCaseSensitive()
                                 ? originalpattern == currentelement
                                 : originalpattern.toUpperCase() == currentelement.toUpperCase();
@@ -1089,21 +1087,21 @@ package org.apache.flex.ant.tags.filesetClasses
             if (dir == null) {
                 throw new BuildException("dir must not be null.");
             }
-            var arr:Array = dir.getDirectoryListing();
+            else if (!dir.exists) {
+                throw new BuildException(dir + DOES_NOT_EXIST_POSTFIX);
+            } else if (!dir.isDirectory) {
+                throw new BuildException(dir + " is not a directory.");
+            }
+            try {
+                var arr:Array = dir.getDirectoryListing();                
+            } catch (e:Error) {
+                throw new BuildException("IO error scanning directory '"
+                    + dir.nativePath + "'");
+            }
             var arr2:Array = [];
             for each (var f:File in arr)
-                arr2.push(f.nativePath);
+                arr2.push(f.name);
             var newfiles:Vector.<String> = Vector.<String>(arr2);;
-            if (newfiles == null) {
-                if (!dir.exists) {
-                    throw new BuildException(dir + DOES_NOT_EXIST_POSTFIX);
-                } else if (!dir.isDirectory) {
-                    throw new BuildException(dir + " is not a directory.");
-                } else {
-                    throw new BuildException("IO error scanning directory '"
-                        + dir.nativePath + "'");
-                }
-            }
             _scandir(dir, path, fast, newfiles, new Vector.<String>());
         }
         
@@ -1150,11 +1148,16 @@ package org.apache.flex.ant.tags.filesetClasses
                     name = vpath + newfiles[i];
                     var newPath:TokenizedPath = new TokenizedPath("").initAsChild(path, newfiles[i]);
                     file = new File(dir.nativePath + File.separator + newfiles[i]);
-                    var arr:Array = file.getDirectoryListing();
+                    var arr:Array = null;
                     var arr2:Array = [];
-                    for each (var f:File in arr)
-                        arr2.push(f.nativePath);
-                    var children:Vector.<String> = Vector.<String>(arr2);
+                    var children:Vector.<String> = null;
+                    if (file.isDirectory)
+                    {
+                        arr = file.getDirectoryListing();
+                        for each (var f:File in arr)
+                            arr2.push(f.name);
+                        children = Vector.<String>(arr2);
+                    }
                     if (children == null || (children.length == 0 && !file.isDirectory))
{
                         if (isIncludedPath(newPath)) {
                             accountForIncludedFile(newPath, file);
@@ -1272,8 +1275,8 @@ package org.apache.flex.ant.tags.filesetClasses
             ensureNonPatternSetsReady();
             
             if (isCaseSensitive()
-                ? includeNonPatterns.containsKey(path.toString())
-                : includeNonPatterns.containsKey(path.toString().toUpperCase())) {
+                ? includeNonPatterns.hasOwnProperty(path.toString())
+                : includeNonPatterns.hasOwnProperty(path.toString().toUpperCase())) {
                 return true;
             }
             for (var i:int = 0; i < includePatterns.length; i++) {
@@ -1668,8 +1671,8 @@ package org.apache.flex.ant.tags.filesetClasses
          * @since Ant 1.6
          */
         private function clearCaches():void {
-            includeNonPatterns.clear();
-            excludeNonPatterns.clear();
+            includeNonPatterns = {};
+            excludeNonPatterns = {};
             includePatterns = null;
             excludePatterns = null;
             areNonPatternSetsReady = false;
@@ -1698,7 +1701,7 @@ package org.apache.flex.ant.tags.filesetClasses
          * @since Ant 1.8.0
          */
         private function fillNonPatternSet(map:Object, patterns:Vector.<String>):Vector.<TokenizedPattern>
{
-            var al:Vector.<TokenizedPattern> = new Vector.<TokenizedPattern>(patterns.length);
+            var al:Vector.<TokenizedPattern> = new Vector.<TokenizedPattern>();
             for (var i:int = 0; i < patterns.length; i++) {
                 if (!SelectorUtils.hasWildcards(patterns[i])) {
                     var s:String = isCaseSensitive()

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/FileUtils.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/FileUtils.as b/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/FileUtils.as
index d0409ca..146b972 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/FileUtils.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/FileUtils.as
@@ -175,7 +175,7 @@ package org.apache.flex.ant.tags.filesetClasses
             var sep:String = File.separator;
             filename = filename.replace(/\//g, sep).replace(/\\/g, sep);
             var c:String = filename.charAt(0);
-            if (ON_DOS)
+            if (!ON_DOS)
                 return (c == sep);
             
             if (c == sep) {
@@ -258,7 +258,7 @@ package org.apache.flex.ant.tags.filesetClasses
                     continue;
                 }
                 if (".." == thisToken) {
-                    if (s.size() < 2) {
+                    if (s.length < 2) {
                         // Cannot resolve it, so skip it.
                         return new File(path);
                     }
@@ -268,14 +268,14 @@ package org.apache.flex.ant.tags.filesetClasses
                 }
             }
             var sb:String = "";
-            var size:int = s.size();
+            var size:int = s.length;
             for (var i:int = 0; i < size; i++) {
                 if (i > 1) {
                     // not before the filesystem root and not after it, since root
                     // already contains one
                     sb += File.separator;
                 }
-                sb += s.elementAt(i);
+                sb += s[i];
             }
             return new File(sb);
         }

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/StringTokenizer.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/StringTokenizer.as b/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/StringTokenizer.as
index fcd97ba..02ddff5 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/StringTokenizer.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/StringTokenizer.as
@@ -27,29 +27,35 @@ package org.apache.flex.ant.tags.filesetClasses
             var c1:int = 0;
             var c2:int = 0;
             var n:int = s.length;
-            while (c1 < n)
+            while (c2 < n)
             {
                 var c:String = s.charAt(c2);
                 if (delims.indexOf(c) != -1)
                 {
-                    tokens.push(s.substring(c1, c2 - 1));
+                    tokens.push(s.substring(c1, c2));
                     c1 = c2;
-                    while (c1 < n)
+                    while (c2 < n)
                     {
                         c = s.charAt(c2);
                         if (delims.indexOf(c) == -1)
                         {
                             if (returnDelims)
-                            {
-                                tokens.push(s.substring(c1, c2 - 1))
-                            }
+                                tokens.push(s.substring(c1, c2))
                             c1 = c2;
                             break;
                         }
+                        c2++;
+                    }
+                    if (returnDelims && c1 < c2)
+                    {
+                        tokens.push(s.substring(c1, c2));
+                        c1 = c2;
                     }
                 }
                 c2++;
             }
+            if (c1 < n)
+                tokens.push(s.substring(c1))
         }
         
         private var tokens:Vector.<String>;

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/FileSetTaskHandler.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/FileSetTaskHandler.as
b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/FileSetTaskHandler.as
index c399e52..c0320a8 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/FileSetTaskHandler.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/FileSetTaskHandler.as
@@ -18,6 +18,8 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.ant.tags.supportClasses
 {
+    import flash.filesystem.File;
+    
     import org.apache.flex.ant.tags.FileSet;
     
     /**
@@ -47,9 +49,10 @@ package org.apache.flex.ant.tags.supportClasses
                     var list:Vector.<String> = fs.value as Vector.<String>;
                     if (list)
                     {
+                        var dir:File = new File(fs.dir);
                         for each (var fileName:String in list)
                         {
-                            actOnFile(fs.dir, fileName);
+                            actOnFile(dir.nativePath, fileName);
                         }
                     }
                 }

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/tests/TestTarget.as
----------------------------------------------------------------------
diff --git a/ant_on_air/tests/TestTarget.as b/ant_on_air/tests/TestTarget.as
index 1235d41..722986a 100644
--- a/ant_on_air/tests/TestTarget.as
+++ b/ant_on_air/tests/TestTarget.as
@@ -23,9 +23,16 @@ package
     import flash.events.Event;
     import flash.filesystem.File;
     import org.apache.flex.ant.Ant;
+    import org.apache.flex.ant.tags.Available; Available.init(null);
     import org.apache.flex.ant.tags.Condition; Condition.init(null);
+    import org.apache.flex.ant.tags.Copy; Copy.init(null);
+    import org.apache.flex.ant.tags.Delete; Delete.init(null);
     import org.apache.flex.ant.tags.Echo; Echo.init(null);
+    import org.apache.flex.ant.tags.FileSet; FileSet.init(null);
+    import org.apache.flex.ant.tags.FileSetExclude; FileSetExclude.init(null);
+    import org.apache.flex.ant.tags.FileSetInclude; FileSetInclude.init(null);
     import org.apache.flex.ant.tags.IsSet; IsSet.init(null);
+    import org.apache.flex.ant.tags.Mkdir; Mkdir.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);

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/tests/test.xml
----------------------------------------------------------------------
diff --git a/ant_on_air/tests/test.xml b/ant_on_air/tests/test.xml
index 5d55451..8114225 100644
--- a/ant_on_air/tests/test.xml
+++ b/ant_on_air/tests/test.xml
@@ -45,6 +45,26 @@
 
 	<target name="test">
 		<echo>FLEX_HOME is ${FLEX_HOME}. DEBUG is ${DEBUG_FLAG}. The OS is ${theOS}</echo>
+        <mkdir dir="${basedir}/temp" />
+        <copy file="${basedir}/test.xml" toFile="${basedir}/temp/copied.xml" />
+        <available file="${basedir}/temp/copied.xml" property="copied.doesnt.exist" value="got
copied" />
+        <echo>copied ${copied.doesnt.exist}.  Should say: got copied</echo>
+        <copy toDir="${basedir}/temp">
+            <fileset dir="${basedir}/../src">
+                <include name="**/**" />
+                <exclude name="**/Ant.as" />
+            </fileset>
+        </copy>
+        <available file="${basedir}/temp/org/apache/flex/ant/Ant.as" property="ant.doesnt.exist"
value="got copied" />
+        <echo>Ant.as ${ant.doesnt.exist}. Should NOT say: got copied</echo>
+        <available file="${basedir}/temp/org/apache/flex/ant/tags/Project.as" property="project.doesnt.exist"
value="got copied" />
+        <echo>Project.as ${project.doesnt.exist}. Should say: got copied</echo>
+        <delete file="${basedir}/temp/copied.xml" />
+        <available file="${basedir}/temp/copied.xml" property="copied.doesnt.exist.after.delete"
value="didn't get deleted" />
+        <echo>copied.xml ${copied.doesnt.exist.after.delete}. Should NOT say: didn't
get deleted</echo>
+        <delete dir="${basedir}/temp" />
+        <available file="${basedir}/temp/org/apache/flex/ant/tags/Project.as" property="project.doesnt.exist.after.delete"
value="didn't get deleted" />
+        <echo>Project.as ${project.doesnt.exist.after.delete}. Should NOT say: didn't
get deleted</echo>
 	</target>
 
     <target name="build" depends="init,compile"


Mime
View raw message