You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2014/01/05 07:32:56 UTC
[1/4] git commit: [flex-utilities] [refs/heads/develop] - add Move
task
Updated Branches:
refs/heads/develop 0dace696b -> e5fea860d
add Move task
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/15de3174
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/15de3174
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/15de3174
Branch: refs/heads/develop
Commit: 15de3174a8fdc3549b3cd40eb8602edc004686cd
Parents: 0dace69
Author: Alex Harui <ah...@apache.org>
Authored: Thu Jan 2 22:19:13 2014 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Thu Jan 2 22:19:13 2014 -0800
----------------------------------------------------------------------
ant_on_air/src/AntClasses.as | 1 +
ant_on_air/src/org/apache/flex/ant/tags/Move.as | 200 +++++++++++++++++++
ant_on_air/tests/test.xml | 10 +
3 files changed, 211 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/15de3174/ant_on_air/src/AntClasses.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/AntClasses.as b/ant_on_air/src/AntClasses.as
index d781e69..95542c2 100644
--- a/ant_on_air/src/AntClasses.as
+++ b/ant_on_air/src/AntClasses.as
@@ -45,6 +45,7 @@ package
import org.apache.flex.ant.tags.LoadProperties; LoadProperties;
import org.apache.flex.ant.tags.Matches; Matches;
import org.apache.flex.ant.tags.Mkdir; Mkdir;
+ import org.apache.flex.ant.tags.Move; Move;
import org.apache.flex.ant.tags.Not; Not;
import org.apache.flex.ant.tags.OS; OS;
import org.apache.flex.ant.tags.Param; Param;
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/15de3174/ant_on_air/src/org/apache/flex/ant/tags/Move.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Move.as b/ant_on_air/src/org/apache/flex/ant/tags/Move.as
new file mode 100644
index 0000000..3b403cc
--- /dev/null
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Move.as
@@ -0,0 +1,200 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 mx.core.IFlexModuleFactory;
+ import mx.resources.ResourceManager;
+
+ import org.apache.flex.ant.Ant;
+ import org.apache.flex.ant.tags.supportClasses.FileSetTaskHandler;
+ import org.apache.flex.xml.ITagHandler;
+
+ [ResourceBundle("ant")]
+ [Mixin]
+ public class Move extends FileSetTaskHandler
+ {
+ public static function init(mf:IFlexModuleFactory):void
+ {
+ Ant.antTagProcessors["move"] = Move;
+ }
+
+ public function Move()
+ {
+ super();
+ }
+
+ private function get fileName():String
+ {
+ return getAttributeValue("@file");
+ }
+
+ private function get toFileName():String
+ {
+ var val:String = getNullOrAttributeValue("@toFile");
+ if (val != null)
+ return val;
+ return getNullOrAttributeValue("@tofile");
+
+ }
+
+ private function get toDirName():String
+ {
+ return getAttributeValue("@todir");
+ }
+
+ private function get overwrite():Boolean
+ {
+ return getAttributeValue("@overwrite") == "true";
+ }
+
+ private var mapper:GlobMapper;
+
+ private function mapFileName(name:String):String
+ {
+ var from:String = mapper.from;
+ if (from.indexOf(".*") == -1)
+ from = from.replace("*", ".*");
+ var regex:RegExp = new RegExp(from);
+ var results:Array = name.match(regex);
+ if (results && results.length == 1)
+ {
+ name = mapper.to.replace("*", results[0]);
+ return name;
+ }
+ return null;
+ }
+
+ private var searchedForMapper:Boolean;
+
+ override protected function actOnFile(dir:String, fileName:String):void
+ {
+ if (!searchedForMapper)
+ {
+ // look for a mapper
+ for (var i:int = 0; i < numChildren; i++)
+ {
+ var child:ITagHandler = getChildAt(i);
+ if (child is GlobMapper)
+ {
+ mapper = child as GlobMapper;
+ mapper.setContext(context);
+ break;
+ }
+ }
+ searchedForMapper = true;
+ }
+
+ var srcName:String;
+ if (dir)
+ srcName = dir + File.separator + fileName;
+ else
+ srcName = fileName;
+ try {
+ var srcFile:File = File.applicationDirectory.resolvePath(srcName);
+ }
+ catch (e:Error)
+ {
+ ant.output(srcName);
+ ant.output(e.message);
+ if (failonerror)
+ ant.project.status = false;
+ return;
+ }
+
+
+ if (mapper)
+ {
+ fileName = mapFileName(fileName);
+ if (fileName == null)
+ return;
+ }
+
+ var destName:String;
+ if (toDirName)
+ destName = toDirName + File.separator + fileName;
+ else
+ destName = toFileName;
+ try {
+ var destFile:File = File.applicationDirectory.resolvePath(destName);
+ }
+ catch (e:Error)
+ {
+ ant.output(destName);
+ ant.output(e.message);
+ if (failonerror)
+ ant.project.status = false;
+ return;
+ }
+
+ srcFile.moveTo(destFile, overwrite);
+ }
+
+ override protected function outputTotal(total:int):void
+ {
+ var s:String = ResourceManager.getInstance().getString('ant', 'COPYFILES');
+ s = s.replace("%1", total.toString());
+ s = s.replace("%2", toDirName);
+ ant.output(ant.formatOutput("copy", s));
+ }
+
+ override public function execute(callbackMode:Boolean, context:Object):Boolean
+ {
+ var retVal:Boolean = super.execute(callbackMode, context);
+ if (numChildren > 0)
+ return retVal;
+
+ try {
+ var srcFile:File = File.applicationDirectory.resolvePath(fileName);
+ }
+ catch (e:Error)
+ {
+ ant.output(fileName);
+ ant.output(e.message);
+ if (failonerror)
+ ant.project.status = false;
+ return true;
+ }
+
+ try {
+ var destFile:File = File.applicationDirectory.resolvePath(toFileName);
+ }
+ catch (e:Error)
+ {
+ ant.output(toFileName);
+ ant.output(e.message);
+ if (failonerror)
+ ant.project.status = false;
+ return true;
+ }
+
+ //var destDir:File = destFile.parent;
+ //var resolveName:String = destFile.nativePath.substr(destFile.nativePath.lastIndexOf(File.separator) + 1);
+ //destDir.resolvePath(resolveName);
+
+ var s:String = ResourceManager.getInstance().getString('ant', 'COPY');
+ s = s.replace("%1", "1");
+ s = s.replace("%2", destFile.nativePath);
+ ant.output(ant.formatOutput("copy", s));
+ srcFile.copyTo(destFile, overwrite);
+ return true;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/15de3174/ant_on_air/tests/test.xml
----------------------------------------------------------------------
diff --git a/ant_on_air/tests/test.xml b/ant_on_air/tests/test.xml
index dafa981..ecc57ca 100644
--- a/ant_on_air/tests/test.xml
+++ b/ant_on_air/tests/test.xml
@@ -74,6 +74,16 @@
</condition>
</fail>
<echo>copied ${copied.doesnt.exist}. Should say: got copied</echo>
+ <move file="${basedir}/temp/copied.xml" toFile="${basedir}/temp/moved.xml" />
+ <available file="${basedir}/temp/moved.xml" property="moved.doesnt.exist" value="got moved" />
+ <fail message="copied.xml was not moved to temp/moved.xml">
+ <condition>
+ <not>
+ <available file="${basedir}/temp/moved.xml" />
+ </not>
+ </condition>
+ </fail>
+ <echo>moved ${moved.doesnt.exist}. Should say: got moved</echo>
<copy todir="${basedir}/temp">
<fileset dir="${basedir}/../src">
<include name="**/**" />
[4/4] git commit: [flex-utilities] [refs/heads/develop] - add move
task
Posted by ah...@apache.org.
add move task
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/e5fea860
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/e5fea860
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/e5fea860
Branch: refs/heads/develop
Commit: e5fea860d8a611f499df0e548e7ff8389cf1aa9e
Parents: 5d5d00f
Author: Alex Harui <ah...@apache.org>
Authored: Sat Jan 4 22:32:29 2014 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Sat Jan 4 22:32:29 2014 -0800
----------------------------------------------------------------------
ant_on_air/locale/en_US/ant.properties | 2 ++
ant_on_air/src/org/apache/flex/ant/tags/Move.as | 23 ++++++++++++++------
ant_on_air/tests/test.xml | 12 +++++-----
3 files changed, 24 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e5fea860/ant_on_air/locale/en_US/ant.properties
----------------------------------------------------------------------
diff --git a/ant_on_air/locale/en_US/ant.properties b/ant_on_air/locale/en_US/ant.properties
index a6a352c..317dcee 100644
--- a/ant_on_air/locale/en_US/ant.properties
+++ b/ant_on_air/locale/en_US/ant.properties
@@ -21,6 +21,8 @@
MKDIR=Created dir: %1
COPY=Copying %1 file to %2
COPYFILES=Copying %1 files to %2
+MOVE=Moving %1 file to %2
+MOVEFILES=Moving %1 files to %2
DELETEFILE=Deleting: %1
DELETEDIR=Deleting directory %1
GETTING=Getting: %1
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e5fea860/ant_on_air/src/org/apache/flex/ant/tags/Move.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Move.as b/ant_on_air/src/org/apache/flex/ant/tags/Move.as
index 3b403cc..244e4ce 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/Move.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Move.as
@@ -149,10 +149,10 @@ package org.apache.flex.ant.tags
override protected function outputTotal(total:int):void
{
- var s:String = ResourceManager.getInstance().getString('ant', 'COPYFILES');
+ var s:String = ResourceManager.getInstance().getString('ant', 'MOVEFILES');
s = s.replace("%1", total.toString());
s = s.replace("%2", toDirName);
- ant.output(ant.formatOutput("copy", s));
+ ant.output(ant.formatOutput("move", s));
}
override public function execute(callbackMode:Boolean, context:Object):Boolean
@@ -173,12 +173,21 @@ package org.apache.flex.ant.tags
return true;
}
+ var destFileName:String;
+ if (toDirName)
+ {
+ var stem:String = srcFile.nativePath.substr(srcFile.parent.nativePath.length);
+ destFileName = toDirName + stem;
+ }
+ else
+ destFileName = toFileName;
+
try {
- var destFile:File = File.applicationDirectory.resolvePath(toFileName);
+ var destFile:File = File.applicationDirectory.resolvePath(destFileName);
}
catch (e:Error)
{
- ant.output(toFileName);
+ ant.output(destFileName);
ant.output(e.message);
if (failonerror)
ant.project.status = false;
@@ -189,11 +198,11 @@ package org.apache.flex.ant.tags
//var resolveName:String = destFile.nativePath.substr(destFile.nativePath.lastIndexOf(File.separator) + 1);
//destDir.resolvePath(resolveName);
- var s:String = ResourceManager.getInstance().getString('ant', 'COPY');
+ var s:String = ResourceManager.getInstance().getString('ant', 'MOVE');
s = s.replace("%1", "1");
s = s.replace("%2", destFile.nativePath);
- ant.output(ant.formatOutput("copy", s));
- srcFile.copyTo(destFile, overwrite);
+ ant.output(ant.formatOutput("move", s));
+ srcFile.moveTo(destFile, overwrite);
return true;
}
}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e5fea860/ant_on_air/tests/test.xml
----------------------------------------------------------------------
diff --git a/ant_on_air/tests/test.xml b/ant_on_air/tests/test.xml
index ecc57ca..ebf9d0f 100644
--- a/ant_on_air/tests/test.xml
+++ b/ant_on_air/tests/test.xml
@@ -107,14 +107,14 @@
</condition>
</fail>
<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" />
- <fail message="temp/copied.xml was not deleted">
+ <delete file="${basedir}/temp/moved.xml" />
+ <available file="${basedir}/temp/moved.xml" property="moved.doesnt.exist.after.delete" value="didn't get deleted" />
+ <fail message="temp/moved.xml was not deleted">
<condition>
- <available file="${basedir}/temp/copied.xml" />
+ <available file="${basedir}/temp/moved.xml" />
</condition>
</fail>
- <echo>copied.xml ${copied.doesnt.exist.after.delete}. Should NOT say: didn't get deleted</echo>
+ <echo>moved.xml ${moved.doesnt.exist.after.delete}. Should NOT say: didn't get deleted</echo>
<get src="http://archive.apache.org/dist/creadur/apache-rat-0.10/apache-rat-0.10-src.zip"
dest="${basedir}/temp" />
<fail message="apache-rat-0.10-src.zip was not copied to temp">
@@ -244,7 +244,7 @@
</fail>
<delete dir="${basedir}/temp" />
<available file="${basedir}/temp/Zorg/apache/flex/ant/tags/Project.as" property="project.doesnt.exist.after.delete" value="didn't get deleted" />
- <fail message="temp/copied.xml was not deleted">
+ <fail message="temp/Project.as was not deleted">
<condition>
<available file="${basedir}/temp/Zorg/apache/flex/ant/tags/Project.as" />
</condition>
[2/4] git commit: [flex-utilities] [refs/heads/develop] - Fix bugs in
exec task
Posted by ah...@apache.org.
Fix bugs in exec task
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/0ed7eeca
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/0ed7eeca
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/0ed7eeca
Branch: refs/heads/develop
Commit: 0ed7eeca4622697a054f793191a30faeed2a135d
Parents: 15de317
Author: Alex Harui <ah...@apache.org>
Authored: Sat Jan 4 22:30:32 2014 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Sat Jan 4 22:30:32 2014 -0800
----------------------------------------------------------------------
ant_on_air/src/org/apache/flex/ant/tags/Exec.as | 39 ++++++++++++++++----
1 file changed, 32 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0ed7eeca/ant_on_air/src/org/apache/flex/ant/tags/Exec.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Exec.as b/ant_on_air/src/org/apache/flex/ant/tags/Exec.as
index f30e68d..bc503a6 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/Exec.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Exec.as
@@ -24,8 +24,6 @@ package org.apache.flex.ant.tags
import flash.events.NativeProcessExitEvent;
import flash.events.ProgressEvent;
import flash.filesystem.File;
- import flash.filesystem.FileMode;
- import flash.filesystem.FileStream;
import flash.system.Capabilities;
import flash.utils.IDataInput;
@@ -56,6 +54,8 @@ package org.apache.flex.ant.tags
var ok:Boolean = false;
for each (var p:String in osArr)
{
+ if (p.toLowerCase() == "windows")
+ p = "win";
if (thisOS.indexOf(p.toLowerCase()) != -1)
{
ok = true;
@@ -78,13 +78,26 @@ package org.apache.flex.ant.tags
args.push("/c");
if (numChildren > 0)
{
- var arg:Arg = getChildAt(0) as Arg;
- arg.setContext(context);
- args.push(fileName + " " + arg.value);
+ var cmdline:String = fileName;
+ for (var i:int = 0; i < numChildren; i++)
+ {
+ var arg:Arg = getChildAt(i) as Arg;
+ arg.setContext(context);
+ cmdline += " " + quoteIfNeeded(arg.value);
+ }
+ args.push(cmdline);
}
else
args.push(fileName);
nativeProcessStartupInfo.arguments = args;
+ if (dir)
+ {
+ var wd:File;
+ wd = File.applicationDirectory;
+ wd = wd.resolvePath(dir);
+ nativeProcessStartupInfo.workingDirectory = wd;
+ }
+
process = new NativeProcess();
process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onOutputErrorData);
@@ -94,6 +107,11 @@ package org.apache.flex.ant.tags
return false;
}
+ private function get dir():String
+ {
+ return getNullOrAttributeValue("@dir");
+ }
+
private function get fileName():String
{
return getAttributeValue("@executable");
@@ -129,8 +147,15 @@ package org.apache.flex.ant.tags
var data:String = stdOut.readUTFBytes(process.standardOutput.bytesAvailable);
trace("Got: ", data);
if (outputProperty)
- context[outputProperty] = data;
+ context[outputProperty] = StringUtil.trim(data);
+ }
+
+ private function quoteIfNeeded(s:String):String
+ {
+ // has spaces but no quotes
+ if (s.indexOf(" ") != -1 && s.indexOf('"') == -1)
+ return '"' + s + '"';
+ return s;
}
-
}
}
\ No newline at end of file
[3/4] git commit: [flex-utilities] [refs/heads/develop] - Use strings
instead of regex for replace task
Posted by ah...@apache.org.
Use strings instead of regex for replace task
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/5d5d00ff
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/5d5d00ff
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/5d5d00ff
Branch: refs/heads/develop
Commit: 5d5d00ff198799f8ae1058d7ce13ea07d8796b77
Parents: 0ed7eec
Author: Alex Harui <ah...@apache.org>
Authored: Sat Jan 4 22:31:34 2014 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Sat Jan 4 22:31:34 2014 -0800
----------------------------------------------------------------------
ant_on_air/src/org/apache/flex/ant/tags/Replace.as | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5d5d00ff/ant_on_air/src/org/apache/flex/ant/tags/Replace.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Replace.as b/ant_on_air/src/org/apache/flex/ant/tags/Replace.as
index dc39b5d..064173a 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/Replace.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Replace.as
@@ -75,13 +75,11 @@ package org.apache.flex.ant.tags
fs.open(f, FileMode.READ);
var s:String = fs.readUTFBytes(fs.bytesAvailable);
fs.close();
- var tokens:Vector.<RegExp> = new Vector.<RegExp>();
+ var tokens:Vector.<String> = new Vector.<String>();
var reps:Vector.<String> = new Vector.<String>();
- var regex:RegExp;
if (token != null)
{
- regex = new RegExp(token, "g");
- tokens.push(regex);
+ tokens.push(token);
reps.push(value);
}
if (numChildren > 0)
@@ -90,15 +88,15 @@ package org.apache.flex.ant.tags
{
var rf:ReplaceFilter = getChildAt(i) as ReplaceFilter;
rf.setContext(context);
- regex = new RegExp(rf.token, "g");
- tokens.push(regex);
+ tokens.push(rf.token);
reps.push(rf.value);
}
}
var n:int = tokens.length;
for (i = 0; i < n; i++)
{
- s = s.replace(tokens[i], reps[i]);
+ while (s.indexOf(tokens[i]) != -1)
+ s = s.replace(tokens[i], reps[i]);
}
fs.open(f, FileMode.WRITE);
fs.writeUTFBytes(s);