incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [8/9] android commit: [CB-659] create script for android on windows now works fully. also pulls down commons-codec jar appropriately
Date Fri, 18 May 2012 21:12:43 GMT
[CB-659] create script for android on windows now works fully. also pulls down commons-codec
jar appropriately


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/1f45503e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/1f45503e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/1f45503e

Branch: refs/heads/463
Commit: 1f45503e2f313e9d13aefc73660c225c0edde3ff
Parents: 7eb3e5d
Author: filmaj <maj.fil@gmail.com>
Authored: Thu May 17 10:59:38 2012 -0700
Committer: filmaj <maj.fil@gmail.com>
Committed: Thu May 17 10:59:38 2012 -0700

----------------------------------------------------------------------
 bin/create.js                           |   44 ++++++++++++++++++++++++-
 bin/templates/project/cordova/create.js |    5 +--
 2 files changed, 44 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/1f45503e/bin/create.js
----------------------------------------------------------------------
diff --git a/bin/create.js b/bin/create.js
index 96e61ec..a15db7a 100644
--- a/bin/create.js
+++ b/bin/create.js
@@ -64,6 +64,9 @@ function fork(s) {
 var args = WScript.Arguments, PROJECT_PATH="example", 
     PACKAGE="org.apache.cordova.example", ACTIVITY="cordovaExample",
     shell=WScript.CreateObject("WScript.Shell");
+    
+// working dir
+var ROOT = WScript.ScriptFullName.split('\\bin\\create.js').join('');
 
 if (args.Count() == 3) {
     WScript.Echo('Found expected arguments');
@@ -86,7 +89,7 @@ WScript.Echo("Activity path: " + ACTIVITY_PATH);
 WScript.Echo("Manifest path: " + MANIFEST_PATH);
 WScript.Echo("Cordova version: " + VERSION);
 
-// clobber any existing example
+// TODO: clobber any existing example
 
 /*
 if [ $# -eq 0 ]
@@ -101,13 +104,50 @@ exec('android.bat create project --target '+TARGET+' --path '+PROJECT_PATH+'
--p
 // update the cordova framework project to a target that exists on this machine
 exec('android.bat update project --target '+TARGET+' --path framework');
 
+// pull down commons codec if necessary
+var fso = WScript.CreateObject('Scripting.FileSystemObject');
+if (!fso.FileExists(ROOT + '\\framework\\libs\\commons-codec-1.6.jar')) {
+  // We need the .jar
+  var url = 'http://mirror.symnds.com/software/Apache//commons/codec/binaries/commons-codec-1.6-bin.zip';
+  var savePath = ROOT + '\\framework\\libs\\commons-codec-1.6-bin.zip';
+  if (!fso.FileExists(savePath)) {
+    // 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 commons-codec. Please download it yourself and
put into the framework/libs directory. This process may fail now. Sorry.');
+    }
+  }
+  var app = WScript.CreateObject('Shell.Application');
+  var source = app.NameSpace(savePath).Items();
+  var target = app.NameSpace(ROOT + '\\framework\\libs');
+  target.CopyHere(source, 256);
+  
+  // Move the jar into libs
+  fso.MoveFile(ROOT + '\\framework\\libs\\commons-codec-1.6\\commons-codec-1.6.jar', ROOT
+ '\\framework\\libs\\commons-codec-1.6.jar');
+  
+  // Clean up
+  fso.DeleteFile(ROOT + '\\framework\\libs\\commons-codec-1.6-bin.zip');
+  fso.DeleteFolder(ROOT + '\\framework\\libs\\commons-codec-1.6', true);
+}
+
+
 // compile cordova.js and cordova.jar
 // if you see an error about "Unable to resolve target" then you may need to 
 // update your android tools or install an additional Android platform version
 exec('ant.bat -f framework\\build.xml jar');
 
 // copy in the project template
-exec('cmd /c xcopy bin\\templates\\project '+PROJECT_PATH+' /S /Y');
+exec('cmd /c xcopy bin\\templates\\project\\* '+PROJECT_PATH+' /S /Y');
 
 // copy example www assets
 exec('cmd /c xcopy ' + PROJECT_PATH + '\\cordova\\assets ' + PROJECT_PATH + ' /S /Y');

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/1f45503e/bin/templates/project/cordova/create.js
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/create.js b/bin/templates/project/cordova/create.js
index b87f0a1..2bf5603 100644
--- a/bin/templates/project/cordova/create.js
+++ b/bin/templates/project/cordova/create.js
@@ -9,7 +9,6 @@ function exec(s, output) {
     WScript.Echo("Command exited with code " + o.Status);
 }
 function read(filename) {
-    WScript.Echo('Reading in ' + filename);
     var fso=WScript.CreateObject("Scripting.FileSystemObject");
     var f=fso.OpenTextFile(filename, 1);
     var s=f.ReadAll();
@@ -44,7 +43,7 @@ var MANIFEST_PATH=PWD+'\\AndroidManifest.xml';
 exec('android.bat create project --target ' + TARGET + ' --path ' + PWD + ' --package ' +
PACKAGE + ' --activity ' + ACTIVITY);
 
 // copy in activity and other android assets
-exec('cmd /c xcopy ' + PWD + '\\cordova\\templates\project\* ' + PWD +' /Y /S');
+exec('cmd /c xcopy ' + PWD + '\\cordova\\templates\\project\\* ' + PWD +' /Y /S');
 
 // copy in cordova.js
 exec('cmd /c copy ' + PWD + '\\.cordova\\android\\cordova-' + VERSION + '.js ' + PWD + '\\assets\\www
/Y');
@@ -67,4 +66,4 @@ replaceInFile(ACTIVITY_PATH, /__ID__/, PACKAGE);
 replaceInFile(MANIFEST_PATH, /__ACTIVITY__/, ACTIVITY);
 replaceInFile(MANIFEST_PATH, /__PACKAGE__/, PACKAGE);
 
-WScript.Echo('DONE!');
\ No newline at end of file
+WScript.Echo('Create completed successfully.');
\ No newline at end of file


Mime
View raw message