You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2012/09/19 22:57:28 UTC

webworks commit: [CB-1493] - antcontrib download function for windows create script

Updated Branches:
  refs/heads/master bf85a57de -> 887626689


[CB-1493] - antcontrib download function for windows create script


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/commit/88762668
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/tree/88762668
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/diff/88762668

Branch: refs/heads/master
Commit: 887626689f92dfefdd9375e93fc530020f43dacf
Parents: bf85a57
Author: Tim Kim <ti...@nitobi.com>
Authored: Tue Sep 18 17:39:45 2012 -0700
Committer: Tim Kim <ti...@nitobi.com>
Committed: Tue Sep 18 17:39:45 2012 -0700

----------------------------------------------------------------------
 bin/create.js |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/88762668/bin/create.js
----------------------------------------------------------------------
diff --git a/bin/create.js b/bin/create.js
index 2b777c2..bfbbb92 100644
--- a/bin/create.js
+++ b/bin/create.js
@@ -42,6 +42,45 @@ function write(filename, contents) {
 function replaceInFile(filename, regexp, replacement) {
     write(filename, read(filename).replace(regexp, replacement));
 }
+function downloadAntContrib(){
+    if (!fso.FileExists(ROOT + '\\bin\\templates\\project\\lib\\ant-contrib\\ant-contrib-1.0b3.jar)) {
+      // We need the .jar
+      var url = 'http://sourceforge.net/projects/ant-contrib/files/ant-contrib/1.0b3/ant-contrib-1.0b3-bin.zip';
+      var libsPath = ROOT + '\\bin\\templates\\project\\lib';
+      var savePath = libsPath + '\\ant-contrib-1.0b3-bin.zip';
+      if (!fso.FileExists(savePath)) {
+        if(!fso.FolderExists(libsPath)) {
+            fso.CreateFolder(libsPath);
+        }
+        // We need the zip to get the jar
+        var xhr = WScript.CreateObject('MSXML2.XMLHTTP');
+        xhr.open('GET', url, false);
+        xhr.send();
+        if (xhr.status == 200) {
+          var stream = WScript.CreateObject('ADODB.Stream');
+          stream.Open();
+          stream.Type = 1;
+          stream.Write(xhr.ResponseBody);
+          stream.Position = 0;
+          stream.SaveToFile(savePath);
+          stream.Close();
+        } else {
+          WScript.Echo('Could not retrieve the antcontrib. Please download it yourself and put into the bin/templates/project/lib directory. This process may fail now. Sorry.');
+        }
+      }
+      var app = WScript.CreateObject('Shell.Application');
+      var source = app.NameSpace(savePath).Items();
+      var target = app.NameSpace(libsPath);
+      target.CopyHere(source, 256);
+      
+      // Move the jar into libs
+      //fso.MoveFile(ROOT + '\\framework\\libs\\commons-codec-1.7\\commons-codec-1.7.jar', ROOT + '\\framework\\libs\\commons-codec-1.7.jar');
+      
+      // Clean up
+      //fso.DeleteFile(ROOT + '\\framework\\libs\\commons-codec-1.7-bin.zip');
+      //fso.DeleteFolder(ROOT + '\\framework\\libs\\commons-codec-1.7', true);
+    }
+}
 function exec(s, output) {
     var o=shell.Exec(s);
     while (o.Status == 0) {
@@ -81,6 +120,7 @@ var MANIFEST_PATH=PROJECT_PATH+'\\www\\config.xml';
 var VERSION=read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,'');
 
 if(fso.FolderExists(ROOT+'\\framework')){
+    downloadAntContrib();
     exec('ant.bat -f '+ ROOT +'\\build.xml dist');
     // copy in the project template
     exec('cmd /c xcopy '+ ROOT + '\\dist\\sample\\* '+PROJECT_PATH+' /I /S /Y');