Updated Branches: refs/heads/develop e4f33bbca -> 0dace696b
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0dace696/ant_on_air/src/org/apache/flex/ant/tags/Unzip.as ---------------------------------------------------------------------- diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Unzip.as b/ant_on_air/src/org/apache/flex/ant/tags/Unzip.as index 009d29b..45894e3 100644 --- a/ant_on_air/src/org/apache/flex/ant/tags/Unzip.as +++ b/ant_on_air/src/org/apache/flex/ant/tags/Unzip.as @@ -35,7 +35,7 @@ package org.apache.flex.ant.tags import org.as3commons.zip.ZipEvent; import org.as3commons.zip.ZipFile; - [ResourceBundle("ant")] + [ResourceBundle("ant")] [Mixin] public class Unzip extends TaskHandler { @@ -43,57 +43,88 @@ package org.apache.flex.ant.tags { Ant.antTagProcessors["unzip"] = Unzip; } - + public function Unzip() { super(); } - private function get src():String - { - return getAttributeValue("@src"); - } - - private function get dest():String - { - return getAttributeValue("@dest"); - } - - private function get overwrite():Boolean - { - return getAttributeValue("@overwrite") == "true"; - } + private function get src():String + { + return getAttributeValue("@src"); + } + + private function get dest():String + { + return getAttributeValue("@dest"); + } + + private function get overwrite():Boolean + { + return getAttributeValue("@overwrite") == "true"; + } + private var srcFile:File; private var destFile:File; - private var patternSet:PatternSet; + private var patternSet:PatternSet; override public function execute(callbackMode:Boolean, context:Object):Boolean { super.execute(callbackMode, context); - if (numChildren > 0) - { - // look for a patternset - for (var i:int = 0; i < numChildren; i++) - { - var child:ITagHandler = getChildAt(i); - if (child is PatternSet) - { - patternSet = child as PatternSet; - break; - } - } - } - - var srcFile:File = File.applicationDirectory.resolvePath(src); - destFile = File.applicationDirectory.resolvePath(dest); - - var s:String = ResourceManager.getInstance().getString('ant', 'UNZIP'); - s = s.replace("%1", srcFile.nativePath); - s = s.replace("%2", destFile.nativePath); - ant.output(ant.formatOutput("unzip", s)); - + if (numChildren > 0) + { + // look for a patternset + for (var i:int = 0; i < numChildren; i++) + { + var child:ITagHandler = getChildAt(i); + if (child is PatternSet) + { + patternSet = child as PatternSet; + patternSet.setContext(context); + break; + } + } + } + + try { + srcFile = File.applicationDirectory.resolvePath(src); + } + catch (e:Error) + { + ant.output(src); + ant.output(e.message); + if (failonerror) + ant.project.status = false; + return true; + } + + try { + destFile = File.applicationDirectory.resolvePath(dest); + if (!destFile.exists) + destFile.createDirectory(); + } + catch (e:Error) + { + ant.output(dest); + ant.output(e.message); + if (failonerror) + ant.project.status = false; + return true; + } + + + var s:String = ResourceManager.getInstance().getString('ant', 'UNZIP'); + s = s.replace("%1", srcFile.nativePath); + s = s.replace("%2", destFile.nativePath); + ant.output(ant.formatOutput("unzip", s)); + ant.functionToCall = dounzip; + return false; + } + + private function dounzip():void + { unzip(srcFile); - return true; + dispatchEvent(new Event(Event.COMPLETE)); } private function unzip(fileToUnzip:File):void { @@ -108,7 +139,7 @@ package org.apache.flex.ant.tags fzip.addEventListener(ZipEvent.FILE_LOADED, onFileLoaded); fzip.addEventListener(Event.COMPLETE, onUnzipComplete, false, 0, true); fzip.addEventListener(ErrorEvent.ERROR, onUnzipError, false, 0, true); - + // synchronous, so no progress events fzip.loadBytes(zipFileBytes); } @@ -123,11 +154,11 @@ package org.apache.flex.ant.tags private function onFileLoaded(e:ZipEvent):void { try { var fzf:ZipFile = e.file; - if (patternSet) - { - if (!(patternSet.matches(fzf.filename))) - return; - } + if (patternSet) + { + if (!(patternSet.matches(fzf.filename))) + return; + } var f:File = destFile.resolvePath(fzf.filename); var fs:FileStream = new FileStream(); @@ -135,7 +166,7 @@ package org.apache.flex.ant.tags // Is a directory, not a file. Dont try to write anything into it. return; } - + fs.open(f, FileMode.WRITE); fs.writeBytes(fzf.content); fs.close(); @@ -153,7 +184,7 @@ package org.apache.flex.ant.tags fzip.removeEventListener(Event.COMPLETE, onUnzipComplete); fzip.removeEventListener(ErrorEvent.ERROR, onUnzipError); } - + private function onUnzipError(event:Event):void { var fzip:Zip = event.target as Zip; fzip.close(); http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0dace696/ant_on_air/src/org/apache/flex/ant/tags/XmlProperty.as ---------------------------------------------------------------------- diff --git a/ant_on_air/src/org/apache/flex/ant/tags/XmlProperty.as b/ant_on_air/src/org/apache/flex/ant/tags/XmlProperty.as index de818ee..b59f004 100644 --- a/ant_on_air/src/org/apache/flex/ant/tags/XmlProperty.as +++ b/ant_on_air/src/org/apache/flex/ant/tags/XmlProperty.as @@ -34,16 +34,27 @@ package org.apache.flex.ant.tags { Ant.antTagProcessors["xmlproperty"] = XmlProperty; } - + public function XmlProperty() { } override public function execute(callbackMode:Boolean, context:Object):Boolean { - super.execute(callbackMode, context); - - var f:File = new File(fileName); + super.execute(callbackMode, context); + + try { + var f:File = new File(fileName); + } + catch (e:Error) + { + ant.output(fileName); + ant.output(e.message); + if (failonerror) + ant.project.status = false; + return true; + } + var fs:FileStream = new FileStream(); fs.open(f, FileMode.READ); var data:String = fs.readUTFBytes(fs.bytesAvailable); @@ -70,6 +81,9 @@ package org.apache.flex.ant.tags else if (node.nodeKind() == "element") { key = prefix + "." + node.name(); + var id:String = [email protected](); + if (id) + ant.project.refids[id] = key; createProperties(node, key); } } @@ -88,14 +102,14 @@ package org.apache.flex.ant.tags } private function get fileName():String - { - return getAttributeValue("@file"); - } - + { + return getAttributeValue("@file"); + } + private function get collapse():Boolean - { - return getAttributeValue("@collapseAttributes") == "true"; - } + { + return getAttributeValue("@collapseAttributes") == "true"; + } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0dace696/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 3257fc9..362fbaa 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 @@ -113,7 +113,7 @@ package org.apache.flex.ant.tags.filesetClasses * */ public class DirectoryScanner - /* implements FileScanner, SelectorScanner, ResourceFactory*/ { + /* implements FileScanner, SelectorScanner, ResourceFactory*/ { /** * Patterns which should be excluded by default. @@ -130,49 +130,49 @@ package org.apache.flex.ant.tags.filesetClasses protected static const DEFAULTEXCLUDES:Vector.<String> = Vector.<String>([ // Miscellaneous typical temporary files SelectorUtils.DEEP_TREE_MATCH + "/*~", - SelectorUtils.DEEP_TREE_MATCH + "/#*#", - SelectorUtils.DEEP_TREE_MATCH + "/.#*", - SelectorUtils.DEEP_TREE_MATCH + "/%*%", - SelectorUtils.DEEP_TREE_MATCH + "/._*", - - // CVS - SelectorUtils.DEEP_TREE_MATCH + "/CVS", - SelectorUtils.DEEP_TREE_MATCH + "/CVS/" + SelectorUtils.DEEP_TREE_MATCH, - SelectorUtils.DEEP_TREE_MATCH + "/.cvsignore", - - // SCCS - SelectorUtils.DEEP_TREE_MATCH + "/SCCS", - SelectorUtils.DEEP_TREE_MATCH + "/SCCS/" + SelectorUtils.DEEP_TREE_MATCH, - - // Visual SourceSafe - SelectorUtils.DEEP_TREE_MATCH + "/vssver.scc", - - // Subversion - SelectorUtils.DEEP_TREE_MATCH + "/.svn", - SelectorUtils.DEEP_TREE_MATCH + "/.svn/" + SelectorUtils.DEEP_TREE_MATCH, - - // Git - SelectorUtils.DEEP_TREE_MATCH + "/.git", - SelectorUtils.DEEP_TREE_MATCH + "/.git/" + SelectorUtils.DEEP_TREE_MATCH, - SelectorUtils.DEEP_TREE_MATCH + "/.gitattributes", - SelectorUtils.DEEP_TREE_MATCH + "/.gitignore", - SelectorUtils.DEEP_TREE_MATCH + "/.gitmodules", - - // Mercurial - SelectorUtils.DEEP_TREE_MATCH + "/.hg", - SelectorUtils.DEEP_TREE_MATCH + "/.hg/" + SelectorUtils.DEEP_TREE_MATCH, - SelectorUtils.DEEP_TREE_MATCH + "/.hgignore", - SelectorUtils.DEEP_TREE_MATCH + "/.hgsub", - SelectorUtils.DEEP_TREE_MATCH + "/.hgsubstate", - SelectorUtils.DEEP_TREE_MATCH + "/.hgtags", - - // Bazaar - SelectorUtils.DEEP_TREE_MATCH + "/.bzr", - SelectorUtils.DEEP_TREE_MATCH + "/.bzr/" + SelectorUtils.DEEP_TREE_MATCH, - SelectorUtils.DEEP_TREE_MATCH + "/.bzrignore", - - // Mac - SelectorUtils.DEEP_TREE_MATCH + "/.DS_Store" + SelectorUtils.DEEP_TREE_MATCH + "/#*#", + SelectorUtils.DEEP_TREE_MATCH + "/.#*", + SelectorUtils.DEEP_TREE_MATCH + "/%*%", + SelectorUtils.DEEP_TREE_MATCH + "/._*", + + // CVS + SelectorUtils.DEEP_TREE_MATCH + "/CVS", + SelectorUtils.DEEP_TREE_MATCH + "/CVS/" + SelectorUtils.DEEP_TREE_MATCH, + SelectorUtils.DEEP_TREE_MATCH + "/.cvsignore", + + // SCCS + SelectorUtils.DEEP_TREE_MATCH + "/SCCS", + SelectorUtils.DEEP_TREE_MATCH + "/SCCS/" + SelectorUtils.DEEP_TREE_MATCH, + + // Visual SourceSafe + SelectorUtils.DEEP_TREE_MATCH + "/vssver.scc", + + // Subversion + SelectorUtils.DEEP_TREE_MATCH + "/.svn", + SelectorUtils.DEEP_TREE_MATCH + "/.svn/" + SelectorUtils.DEEP_TREE_MATCH, + + // Git + SelectorUtils.DEEP_TREE_MATCH + "/.git", + SelectorUtils.DEEP_TREE_MATCH + "/.git/" + SelectorUtils.DEEP_TREE_MATCH, + SelectorUtils.DEEP_TREE_MATCH + "/.gitattributes", + SelectorUtils.DEEP_TREE_MATCH + "/.gitignore", + SelectorUtils.DEEP_TREE_MATCH + "/.gitmodules", + + // Mercurial + SelectorUtils.DEEP_TREE_MATCH + "/.hg", + SelectorUtils.DEEP_TREE_MATCH + "/.hg/" + SelectorUtils.DEEP_TREE_MATCH, + SelectorUtils.DEEP_TREE_MATCH + "/.hgignore", + SelectorUtils.DEEP_TREE_MATCH + "/.hgsub", + SelectorUtils.DEEP_TREE_MATCH + "/.hgsubstate", + SelectorUtils.DEEP_TREE_MATCH + "/.hgtags", + + // Bazaar + SelectorUtils.DEEP_TREE_MATCH + "/.bzr", + SelectorUtils.DEEP_TREE_MATCH + "/.bzr/" + SelectorUtils.DEEP_TREE_MATCH, + SelectorUtils.DEEP_TREE_MATCH + "/.bzrignore", + + // Mac + SelectorUtils.DEEP_TREE_MATCH + "/.DS_Store" ]); /** @@ -404,7 +404,7 @@ package org.apache.flex.ant.tags.filesetClasses */ public function DirectoryScanner() { } - + /** * Test whether or not a given path matches the start of a given * pattern up to the first "**". @@ -424,10 +424,10 @@ package org.apache.flex.ant.tags.filesetClasses * pattern up to the first "**". */ protected static function matchPatternStart(pattern:String, str:String, - isCaseSensitive:Boolean = true):Boolean { - return SelectorUtils.matchPatternStart(pattern, str, isCaseSensitive); - } - + isCaseSensitive:Boolean = true):Boolean { + return SelectorUtils.matchPatternStart(pattern, str, isCaseSensitive); + } + /** * Test whether or not a given path matches a given pattern. * @@ -442,9 +442,9 @@ package org.apache.flex.ant.tags.filesetClasses * or <code>false</code> otherwise. */ protected static function matchPath(pattern:String, str:String, - isCaseSensitive:Boolean = true):Boolean { - return SelectorUtils.matchPath(pattern, str, isCaseSensitive); - } + isCaseSensitive:Boolean = true):Boolean { + return SelectorUtils.matchPath(pattern, str, isCaseSensitive); + } /** * Test whether or not a string matches against a pattern. @@ -464,9 +464,9 @@ package org.apache.flex.ant.tags.filesetClasses * or <code>false</code> otherwise. */ protected static function match(pattern:String, str:String, - isCaseSensitive:Boolean = true):Boolean{ - return SelectorUtils.match(pattern, str, isCaseSensitive); - } + isCaseSensitive:Boolean = true):Boolean{ + return SelectorUtils.match(pattern, str, isCaseSensitive); + } /** @@ -479,7 +479,7 @@ package org.apache.flex.ant.tags.filesetClasses * @since Ant 1.6 */ public static function getDefaultExcludes():Vector.<String> { - return defaultExcludes.slice(); + return defaultExcludes.slice(); } /** @@ -526,14 +526,14 @@ package org.apache.flex.ant.tags.filesetClasses * @since Ant 1.6 */ public static function resetDefaultExcludes():Vector.<String> { - var arr:Vector.<String> = defaultExcludes; - if (!arr) - arr = new Vector.<String>(); - arr.length = 0; - for (var i:int = 0; i < DEFAULTEXCLUDES.length; i++) { - arr.push(DEFAULTEXCLUDES[i]); - } - return arr; + var arr:Vector.<String> = defaultExcludes; + if (!arr) + arr = new Vector.<String>(); + arr.length = 0; + for (var i:int = 0; i < DEFAULTEXCLUDES.length; i++) { + arr.push(DEFAULTEXCLUDES[i]); + } + return arr; } /** @@ -550,7 +550,7 @@ package org.apache.flex.ant.tags.filesetClasses else setBasedirFile(basedir == null ? null : new File(basedir.replace('/', File.separator).replace( - '\\', File.separator))); + '\\', File.separator))); } /** @@ -562,7 +562,7 @@ package org.apache.flex.ant.tags.filesetClasses public function setBasedirFile(basedir:File):void { this.basedir = basedir; } - + /** * Return the base directory to be scanned. * This is the directory which is scanned recursively. @@ -762,64 +762,64 @@ package org.apache.flex.ant.tags.filesetClasses { var savedBase:File = basedir; try { - illegal = null; - clearResults(); - - // set in/excludes to reasonable defaults if needed: - var nullIncludes:Boolean = (includes == null); - includes = nullIncludes - ? Vector.<String>([SelectorUtils.DEEP_TREE_MATCH]) : includes; - var nullExcludes:Boolean = (excludes == null); - excludes = nullExcludes ? new Vector.<String>(0) : excludes; - - if (basedir != null && !followSymlinks - && basedir.isSymbolicLink) { - notFollowedSymlinks.push(basedir.nativePath); - basedir = null; + illegal = null; + clearResults(); + + // set in/excludes to reasonable defaults if needed: + var nullIncludes:Boolean = (includes == null); + includes = nullIncludes + ? Vector.<String>([SelectorUtils.DEEP_TREE_MATCH]) : includes; + var nullExcludes:Boolean = (excludes == null); + excludes = nullExcludes ? new Vector.<String>(0) : excludes; + + if (basedir != null && !followSymlinks + && basedir.isSymbolicLink) { + notFollowedSymlinks.push(basedir.nativePath); + basedir = null; + } + + if (basedir == null) { + // if no basedir and no includes, nothing to do: + if (nullIncludes) { + return; } - - if (basedir == null) { - // if no basedir and no includes, nothing to do: - if (nullIncludes) { - return; - } - } else { - if (!basedir.exists) { - if (errorOnMissingDir) { - illegal = new IllegalStateException("basedir " - + basedir - + DOES_NOT_EXIST_POSTFIX); - } else { - // Nothing to do - basedir does not exist - return; - } - } else if (!basedir.isDirectory) { + } else { + if (!basedir.exists) { + if (errorOnMissingDir) { illegal = new IllegalStateException("basedir " + basedir - + " is not a" - + " directory."); - } - if (illegal != null) { - throw illegal; + + DOES_NOT_EXIST_POSTFIX); + } else { + // Nothing to do - basedir does not exist + return; } + } else if (!basedir.isDirectory) { + illegal = new IllegalStateException("basedir " + + basedir + + " is not a" + + " directory."); } - if (isIncludedPath(TokenizedPath.EMPTY_PATH)) { - if (!isExcludedPath(TokenizedPath.EMPTY_PATH)) { - if (isSelected("", basedir)) { - dirsIncluded.push(""); - } else { - dirsDeselected.push(""); - } + if (illegal != null) { + throw illegal; + } + } + if (isIncludedPath(TokenizedPath.EMPTY_PATH)) { + if (!isExcludedPath(TokenizedPath.EMPTY_PATH)) { + if (isSelected("", basedir)) { + dirsIncluded.push(""); } else { - dirsExcluded.push(""); + dirsDeselected.push(""); } } else { - dirsNotIncluded.push(""); + dirsExcluded.push(""); } - checkIncludePatterns(); - clearCaches(); - includes = nullIncludes ? null : includes; - excludes = nullExcludes ? null : excludes; + } else { + dirsNotIncluded.push(""); + } + checkIncludePatterns(); + clearCaches(); + includes = nullIncludes ? null : includes; + excludes = nullExcludes ? null : excludes; } catch (ex:IOException) { throw new BuildException(ex.message); } catch (e:Error) { @@ -848,14 +848,10 @@ package org.apache.flex.ant.tags.filesetClasses pattern; } } - for each (var entry:Object in includeNonPatterns) { - for (var p:String in entry) - { - pattern = p; - break; - } + for (var p:String in includeNonPatterns) { + pattern = p; if (!shouldSkipPattern(pattern)) { - newroots[entry[pattern]] = pattern; + newroots[includeNonPatterns[pattern]] = pattern; } } @@ -875,7 +871,7 @@ package org.apache.flex.ant.tags.filesetClasses } // only scan directories that can include matched files or // directories - for (entry in newroots) { + for (var entry:Object in newroots) { var currentPath:TokenizedPath; currentPath = entry as TokenizedPath; var currentelement:String = currentPath.toString(); @@ -942,7 +938,7 @@ package org.apache.flex.ant.tags.filesetClasses } } else { var originalpattern:String; - originalpattern = newroots[entry] as String; + originalpattern = newroots[entry] as String; var included:Boolean = isCaseSensitive() ? originalpattern == currentelement : originalpattern.toUpperCase() == currentelement.toUpperCase(); @@ -1005,28 +1001,28 @@ package org.apache.flex.ant.tags.filesetClasses protected function slowScan():void { try { - // set in/excludes to reasonable defaults if needed: - var nullIncludes:Boolean = (includes == null); - includes = nullIncludes - ? Vector.<String>([SelectorUtils.DEEP_TREE_MATCH]) : includes; - var nullExcludes:Boolean = (excludes == null); - excludes = nullExcludes ? new Vector.<String>(0) : excludes; - - var excl:Vector.<String> = dirsExcluded.slice(); - - var notIncl:Vector.<String> = dirsNotIncluded.slice(); - - ensureNonPatternSetsReady(); - - processSlowScan(excl); - processSlowScan(notIncl); - clearCaches(); - includes = nullIncludes ? null : includes; - excludes = nullExcludes ? null : excludes; + // set in/excludes to reasonable defaults if needed: + var nullIncludes:Boolean = (includes == null); + includes = nullIncludes + ? Vector.<String>([SelectorUtils.DEEP_TREE_MATCH]) : includes; + var nullExcludes:Boolean = (excludes == null); + excludes = nullExcludes ? new Vector.<String>(0) : excludes; + + var excl:Vector.<String> = dirsExcluded.slice(); + + var notIncl:Vector.<String> = dirsNotIncluded.slice(); + + ensureNonPatternSetsReady(); + + processSlowScan(excl); + processSlowScan(notIncl); + clearCaches(); + includes = nullIncludes ? null : includes; + excludes = nullExcludes ? null : excludes; } finally { - haveSlowResults = true; - slowScanning = false; - slowScanLock.notifyAll(); + haveSlowResults = true; + slowScanning = false; + slowScanLock.notifyAll(); } } @@ -1100,107 +1096,107 @@ package org.apache.flex.ant.tags.filesetClasses } var arr2:Array = []; for each (var f:File in arr) - arr2.push(f.name); + arr2.push(f.name); var newfiles:Vector.<String> = Vector.<String>(arr2);; _scandir(dir, path, fast, newfiles, new Vector.<String>()); } private function _scandir(dir:File, path:TokenizedPath, fast:Boolean, - newfiles:Vector.<String>, directoryNamesFollowed:Vector.<String>):void { - var vpath:String = path.toString(); - if (vpath.length > 0 && vpath.charAt(vpath.length - 1) != File.separator) { - vpath += File.separator; - } - - // avoid double scanning of directories, can only happen in fast mode - if (fast && hasBeenScanned(vpath)) { - return; - } - if (!followSymlinks) { - var noLinks:Vector.<String> = new Vector.<String>(); - for (i = 0; i < newfiles.length; i++) { - try { - if (new File(dir + File.separator + newfiles[i]).isSymbolicLink) { - var name:String = vpath + newfiles[i]; - var file:File = new File(dir.nativePath + File.separator + newfiles[i]); - (file.isDirectory - ? dirsExcluded : filesExcluded).push(name); - if (!isExcluded(name)) { - notFollowedSymlinks.push(file.nativePath); - } - } else { - noLinks.push(newfiles[i]); + newfiles:Vector.<String>, directoryNamesFollowed:Vector.<String>):void { + var vpath:String = path.toString(); + if (vpath.length > 0 && vpath.charAt(vpath.length - 1) != File.separator) { + vpath += File.separator; + } + + // avoid double scanning of directories, can only happen in fast mode + if (fast && hasBeenScanned(vpath)) { + return; + } + if (!followSymlinks) { + var noLinks:Vector.<String> = new Vector.<String>(); + for (i = 0; i < newfiles.length; i++) { + try { + if (new File(dir + File.separator + newfiles[i]).isSymbolicLink) { + var name:String = vpath + newfiles[i]; + var file:File = new File(dir.nativePath + File.separator + newfiles[i]); + (file.isDirectory + ? dirsExcluded : filesExcluded).push(name); + if (!isExcluded(name)) { + notFollowedSymlinks.push(file.nativePath); } - } catch (ioe:IOException) { - var msg:String = "IOException caught while checking " - + "for links, couldn't get canonical path!"; - // will be caught and redirected to Ant's logging system - Ant.currentAnt.output(msg); + } else { noLinks.push(newfiles[i]); } + } catch (ioe:IOException) { + var msg:String = "IOException caught while checking " + + "for links, couldn't get canonical path!"; + // will be caught and redirected to Ant's logging system + Ant.currentAnt.output(msg); + noLinks.push(newfiles[i]); } - newfiles = noLinks.slice(); - } else { - directoryNamesFollowed.unshift(dir.nativePath); } - - for (var i:int = 0; i < newfiles.length; i++) { - 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 = null; - var arr2:Array = []; - 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); + newfiles = noLinks.slice(); + } else { + directoryNamesFollowed.unshift(dir.nativePath); + } + + for (var i:int = 0; i < newfiles.length; i++) { + 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 = null; + var arr2:Array = []; + 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); + } else { + everythingIncluded = false; + filesNotIncluded.push(name); } - if (children == null || (children.length == 0 && !file.isDirectory)) { - if (isIncludedPath(newPath)) { - accountForIncludedFile(newPath, file); - } else { - everythingIncluded = false; - filesNotIncluded.push(name); - } - } else { // dir - - if (followSymlinks - && causesIllegalSymlinkLoop(newfiles[i], dir, - directoryNamesFollowed)) { - // will be caught and redirected to Ant's logging system - Ant.currentAnt.output("skipping symbolic link " - + file.nativePath - + " -- too many levels of symbolic" - + " links."); - notFollowedSymlinks.push(file.nativePath); - continue; - } - - if (isIncludedPath(newPath)) { - accountForIncludedDir(newPath, file, fast, children, + } else { // dir + + if (followSymlinks + && causesIllegalSymlinkLoop(newfiles[i], dir, + directoryNamesFollowed)) { + // will be caught and redirected to Ant's logging system + Ant.currentAnt.output("skipping symbolic link " + + file.nativePath + + " -- too many levels of symbolic" + + " links."); + notFollowedSymlinks.push(file.nativePath); + continue; + } + + if (isIncludedPath(newPath)) { + accountForIncludedDir(newPath, file, fast, children, + directoryNamesFollowed); + } else { + everythingIncluded = false; + dirsNotIncluded.push(name); + if (fast && couldHoldIncludedPath(newPath) + && !contentsExcluded(newPath)) { + _scandir(file, newPath, fast, children, directoryNamesFollowed); - } else { - everythingIncluded = false; - dirsNotIncluded.push(name); - if (fast && couldHoldIncludedPath(newPath) - && !contentsExcluded(newPath)) { - _scandir(file, newPath, fast, children, - directoryNamesFollowed); - } - } - if (!fast) { - _scandir(file, newPath, fast, children, directoryNamesFollowed); } } + if (!fast) { + _scandir(file, newPath, fast, children, directoryNamesFollowed); + } } - - if (followSymlinks) { - directoryNamesFollowed.shift(); - } } + + if (followSymlinks) { + directoryNamesFollowed.shift(); + } + } /** * Process included file. @@ -1220,36 +1216,46 @@ package org.apache.flex.ant.tags.filesetClasses * @param fast whether to perform fast scans. */ private function accountForIncludedDir(name:TokenizedPath, - file:File, fast:Boolean, - children:Vector.<String> = null, - directoryNamesFollowed:Vector.<String> = null):void { - processIncluded(name, file, dirsIncluded, dirsExcluded, dirsDeselected); - if (fast && couldHoldIncludedPath(name) && !contentsExcluded(name)) { - _scandir(file, name, fast, children, directoryNamesFollowed); + file:File, fast:Boolean, + children:Vector.<String> = null, + directoryNamesFollowed:Vector.<String> = null):void { + processIncluded(name, file, dirsIncluded, dirsExcluded, dirsDeselected); + if (fast && couldHoldIncludedPath(name) && !contentsExcluded(name)) { + if (directoryNamesFollowed == null) + directoryNamesFollowed = new Vector.<String>(); + if (children == null) + { + var listing:Array = file.getDirectoryListing(); + var nameList:Array = []; + for each (var f:File in listing) + nameList.push(f.name); + children = Vector.<String>(nameList); } + _scandir(file, name, fast, children, directoryNamesFollowed); } + } private function processIncluded(path:TokenizedPath, - file:File, inc:Vector.<String>, exc:Vector.<String>, - des:Vector.<String>):void { - var name:String = path.toString(); - if (inc.indexOf(name) != -1 || - exc.indexOf(name) != -1 || - des.indexOf(name) != -1) { - return; - } - - var included:Boolean = false; - if (isExcludedPath(path)) { - exc.push(name); - } else if (isSelected(name, file)) { - included = true; - inc.push(name); - } else { - des.push(name); - } - everythingIncluded = everythingIncluded || included; + file:File, inc:Vector.<String>, exc:Vector.<String>, + des:Vector.<String>):void { + var name:String = path.toString(); + if (inc.indexOf(name) != -1 || + exc.indexOf(name) != -1 || + des.indexOf(name) != -1) { + return; } + + var included:Boolean = false; + if (isExcludedPath(path)) { + exc.push(name); + } else if (isSelected(name, file)) { + included = true; + inc.push(name); + } else { + des.push(name); + } + everythingIncluded = everythingIncluded || included; + } /** * Test whether or not a name matches against at least one include @@ -1331,11 +1337,11 @@ package org.apache.flex.ant.tags.filesetClasses * include pattern, or <code>false</code> otherwise. */ private function couldHoldIncludedWithIncludes(tokenizedName:TokenizedPath, - tokenizedInclude:TokenizedPattern):Boolean { - return tokenizedInclude.matchStartOf(tokenizedName, isCaseSensitive()) - && isMorePowerfulThanExcludes(tokenizedName.toString()) - && isDeeper(tokenizedInclude, tokenizedName); - } + tokenizedInclude:TokenizedPattern):Boolean { + return tokenizedInclude.matchStartOf(tokenizedName, isCaseSensitive()) + && isMorePowerfulThanExcludes(tokenizedName.toString()) + && isDeeper(tokenizedInclude, tokenizedName); + } /** * Verify that a pattern specifies files deeper @@ -1458,7 +1464,7 @@ package org.apache.flex.ant.tags.filesetClasses */ public function getIncludedFiles():Vector.<String> { var files:Vector.<String>; - files = filesIncluded.slice(); + files = filesIncluded.slice(); files.sort(0); return files; } @@ -1535,7 +1541,7 @@ package org.apache.flex.ant.tags.filesetClasses */ public function getIncludedDirectories():Vector.<String> { var directories:Vector.<String>; - directories = dirsIncluded.slice(); + directories = dirsIncluded.slice(); directories.sort(0); return directories; } @@ -1611,7 +1617,7 @@ package org.apache.flex.ant.tags.filesetClasses */ public function getNotFollowedSymlinks():Vector.<String> { var links:Vector.<String>; - links = notFollowedSymlinks.slice(); + links = notFollowedSymlinks.slice(); links.sort(0); return links; } @@ -1726,42 +1732,42 @@ package org.apache.flex.ant.tags.filesetClasses * @since Ant 1.8.0 */ private function causesIllegalSymlinkLoop(dirName:String, parent:File, - directoryNamesFollowed:Vector.<String>):Boolean { - try { - if (directoryNamesFollowed.length >= maxLevelsOfSymlinks - && CollectionUtils.frequency(directoryNamesFollowed, dirName) - >= maxLevelsOfSymlinks - && new File(parent.nativePath + File.separator + dirName).isSymbolicLink) { - - var files:Vector.<String> = new Vector.<String>(); - var f:File = FILE_UTILS.resolveFile(parent, dirName); - f.canonicalize(); - var target:String = f.nativePath; - files.push(target); - - var relPath:String = ""; - for each (var dir:String in directoryNamesFollowed) { - relPath += "../"; - if (dirName == dir) { - f = FILE_UTILS.resolveFile(parent, relPath + dir); - f.canonicalize(); - files.push(f.nativePath); - if (files.length > maxLevelsOfSymlinks - && CollectionUtils.frequency(files, target) - > maxLevelsOfSymlinks) { - return true; - } + directoryNamesFollowed:Vector.<String>):Boolean { + try { + if (directoryNamesFollowed.length >= maxLevelsOfSymlinks + && CollectionUtils.frequency(directoryNamesFollowed, dirName) + >= maxLevelsOfSymlinks + && new File(parent.nativePath + File.separator + dirName).isSymbolicLink) { + + var files:Vector.<String> = new Vector.<String>(); + var f:File = FILE_UTILS.resolveFile(parent, dirName); + f.canonicalize(); + var target:String = f.nativePath; + files.push(target); + + var relPath:String = ""; + for each (var dir:String in directoryNamesFollowed) { + relPath += "../"; + if (dirName == dir) { + f = FILE_UTILS.resolveFile(parent, relPath + dir); + f.canonicalize(); + files.push(f.nativePath); + if (files.length > maxLevelsOfSymlinks + && CollectionUtils.frequency(files, target) + > maxLevelsOfSymlinks) { + return true; } } - } - return false; - } catch (ex:IOException) { - throw new BuildException("Caught error while checking for" - + " symbolic links" + ex.message); + } return false; + } catch (ex:IOException) { + throw new BuildException("Caught error while checking for" + + " symbolic links" + ex.message); } + return false; + } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0dace696/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 5e1f1c8..1a36148 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 @@ -43,7 +43,7 @@ package org.apache.flex.ant.tags.supportClasses /** * Do the work. * TaskHandlers lazily create their children - * and attributes so + * and attributes so * super.execute() should be called before * doing any real work. */ @@ -75,17 +75,17 @@ package org.apache.flex.ant.tags.supportClasses } } } - if (numChildren) - outputTotal(totalFiles); + if (numChildren) + outputTotal(totalFiles); actOnFileSets(); return !callbackMode; } - protected function outputTotal(total:int):void - { - - } - + protected function outputTotal(total:int):void + { + + } + private function actOnFileSets():void { if (current == numChildren) @@ -102,7 +102,18 @@ package org.apache.flex.ant.tags.supportClasses var list:Vector.<String> = fs.getValue(context) as Vector.<String>; if (list) { - currentDir = new File(fs.dir); + try { + currentDir = new File(fs.dir); + } + catch (e:Error) + { + ant.output(fs.dir); + ant.output(e.message); + if (failonerror) + ant.project.status = false; + dispatchEvent(new Event(Event.COMPLETE)); + return; + } currentFile = 0; currentList = list; actOnList(); @@ -111,14 +122,14 @@ package org.apache.flex.ant.tags.supportClasses } } } - - if (current == numChildren) - { - dispatchEvent(new Event(Event.COMPLETE)); - return; - } + + if (current == numChildren) + { + dispatchEvent(new Event(Event.COMPLETE)); + return; + } } - + private function actOnList():void { if (currentFile == currentList.length) http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0dace696/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 index 99ed48f..f4d803a 100644 --- 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 @@ -27,17 +27,12 @@ package org.apache.flex.ant.tags.supportClasses { } - private var _name:String; - /** * The name property. */ public function get name():String { - if (_name == null && xml != null) - _name = [email protected](); - - return _name; + return getNullOrAttributeValue("@name"); } } http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0dace696/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 index 88ec3f4..854d134 100644 --- 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 @@ -47,6 +47,14 @@ package org.apache.flex.ant.tags.supportClasses protected var context:Object; /** + * Set the context + */ + public function setContext(context:Object):void + { + this.context = context; + } + + /** * The xml node for this tag */ protected var xml:XML; @@ -60,19 +68,19 @@ package org.apache.flex.ant.tags.supportClasses this.xml = xml; } - protected function getAttributeValue(name:String):String - { - return ant.getValue(xml[name].toString(), context); - } - - protected function getNullOrAttributeValue(name:String):String - { - var xmlList:XMLList = xml[name]; - if (xmlList.length() == 0) - return null; - - return ant.getValue(xml[name].toString(), context); - } - + protected function getAttributeValue(name:String):String + { + return ant.getValue(xml[name].toString(), context); + } + + protected function getNullOrAttributeValue(name:String):String + { + var xmlList:XMLList = xml[name]; + if (xmlList.length() == 0) + return null; + + return ant.getValue(xml[name].toString(), context); + } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0dace696/ant_on_air/tests/AntOnAir.mxml ---------------------------------------------------------------------- diff --git a/ant_on_air/tests/AntOnAir.mxml b/ant_on_air/tests/AntOnAir.mxml index 040b923..7e6182c 100644 --- a/ant_on_air/tests/AntOnAir.mxml +++ b/ant_on_air/tests/AntOnAir.mxml @@ -37,10 +37,21 @@ limitations under the License. private function checkargs(event:InvokeEvent):void { var targets:Array = []; + + var nextIsAntFile:Boolean; for each (var s:String in event.arguments) { - if (s.indexOf("-f ") != -1) + if (s == "-f") + { + nextIsAntFile = true; + } + else if (nextIsAntFile) + { + nextIsAntFile = false; + antfilename = s; + } + else if (s.indexOf("-f ") != -1) { antfilename = s.substr(3); } http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0dace696/ant_on_air/tests/copyfilesetofone.xml ---------------------------------------------------------------------- diff --git a/ant_on_air/tests/copyfilesetofone.xml b/ant_on_air/tests/copyfilesetofone.xml new file mode 100644 index 0000000..e4d1c9d --- /dev/null +++ b/ant_on_air/tests/copyfilesetofone.xml @@ -0,0 +1,35 @@ +<?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_copy_fileset_of_one" basedir="." default="test"> + + <property name="closure.name" value="compiler" /> + <property name="lib.dir" value="/Users/aharui/Work/apache-flex-flexjs-4.0.1-bin/js/lib" /> + <property name="download.dir" value="/Users/aharui/Work/apache-flex-flexjs-4.0.1-bin/in" /> + + <target name="test" > + <copy todir="${lib.dir}/google/closure-compiler"> + <fileset dir="${download.dir}/temp"> + <include name="${closure.name}.jar"/> + </fileset> + </copy> + </target> + +</project> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0dace696/ant_on_air/tests/redirect.xml ---------------------------------------------------------------------- diff --git a/ant_on_air/tests/redirect.xml b/ant_on_air/tests/redirect.xml new file mode 100644 index 0000000..e5512bc --- /dev/null +++ b/ant_on_air/tests/redirect.xml @@ -0,0 +1,28 @@ +<?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_redirect" basedir="." default="test"> + + <target name="test" > + <get src="http://downloads.sourceforge.net/project/jburg/jburg-1.10.1.tar.gz" + dest="${basedir}" /> + </target> + +</project> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0dace696/ant_on_air/tests/test.xml ---------------------------------------------------------------------- diff --git a/ant_on_air/tests/test.xml b/ant_on_air/tests/test.xml index 907a5af..dafa981 100644 --- a/ant_on_air/tests/test.xml +++ b/ant_on_air/tests/test.xml @@ -64,7 +64,7 @@ <target name="copy-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" /> + <copy file="${basedir}/test.xml" tofile="${basedir}/temp/copied.xml" /> <available file="${basedir}/temp/copied.xml" property="copied.doesnt.exist" value="got copied" /> <fail message="test.xml was not copied to temp/copied.xml"> <condition> @@ -74,7 +74,7 @@ </condition> </fail> <echo>copied ${copied.doesnt.exist}. Should say: got copied</echo> - <copy toDir="${basedir}/temp"> + <copy todir="${basedir}/temp"> <fileset dir="${basedir}/../src"> <include name="**/**" /> <exclude name="**/Ant.as" />
