fixing windows appinfo.jar

This commit is contained in:
Anis Kadri 2012-09-18 14:11:22 -07:00
parent d859bb8e67
commit 45d7c124c8
2 changed files with 21 additions and 5 deletions

View File

@ -17,7 +17,7 @@
@ECHO OFF @ECHO OFF
IF NOT DEFINED JAVA_HOME GOTO MISSING IF NOT DEFINED JAVA_HOME GOTO MISSING
FOR %%X in (java.exe ant.bat android.bat) do ( FOR %%X in (java.exe javac.exe ant.bat android.bat) do (
SET FOUND=%%~$PATH:X SET FOUND=%%~$PATH:X
IF NOT DEFINED FOUND GOTO MISSING IF NOT DEFINED FOUND GOTO MISSING
) )

View File

@ -49,14 +49,24 @@ function replaceInFile(filename, regexp, replacement) {
function exec(command) { function exec(command) {
var oShell=shell.Exec(command); var oShell=shell.Exec(command);
while (oShell.Status == 0) { while (oShell.Status == 0) {
if(!oShell.StdOut.AtEndOfStream) {
var line = oShell.StdOut.ReadLine();
// XXX: Change to verbose mode
WScript.StdOut.WriteLine(line);
}
WScript.sleep(100); WScript.sleep(100);
} }
} }
function createAppInfoJar() { function createAppInfoJar() {
exec("cd "+ROOT+"bin\\templates\\cordova"); if(!fso.FileExists(ROOT+"\\bin\\templates\\cordova\\appinfo.jar")) {
exec("javac bin\\templates\\cordova\\ApplicationInfo\\ApplicationInfo.java"); WScript.Echo("Creating appinfo.jar...");
exec("jar -cfe ..\\appinfo.jar ApplicationInfo ApplicationInfo.class"); var cur = shell.CurrentDirectory;
shell.CurrentDirectory = ROOT+"\\bin\\templates\\cordova\\ApplicationInfo";
exec("javac ApplicationInfo.java");
exec("jar -cfe ..\\appinfo.jar ApplicationInfo ApplicationInfo.class");
shell.CurrentDirectory = cur;
}
} }
function cleanup() { function cleanup() {
@ -119,7 +129,6 @@ var args = WScript.Arguments, PROJECT_PATH="example",
// working dir // working dir
var ROOT = WScript.ScriptFullName.split('\\bin\\create.js').join(''); var ROOT = WScript.ScriptFullName.split('\\bin\\create.js').join('');
WScript.echo("Root Directory:" + ROOT);
if (args.Count() == 3) { if (args.Count() == 3) {
PROJECT_PATH=args(0); PROJECT_PATH=args(0);
@ -138,11 +147,13 @@ var MANIFEST_PATH=PROJECT_PATH+'\\AndroidManifest.xml';
var TARGET=setTarget(); var TARGET=setTarget();
var VERSION=read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,''); var VERSION=read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,'');
// create the project // create the project
WScript.Echo("Creating new android project...");
exec('android.bat create project --target '+TARGET+' --path '+PROJECT_PATH+' --package '+PACKAGE+' --activity '+ACTIVITY); exec('android.bat create project --target '+TARGET+' --path '+PROJECT_PATH+' --package '+PACKAGE+' --activity '+ACTIVITY);
// build from source. distro should have these files // build from source. distro should have these files
if (!fso.FileExists(ROOT+'\\cordova-'+VERSION+'.jar') && if (!fso.FileExists(ROOT+'\\cordova-'+VERSION+'.jar') &&
!fso.FileExists(ROOT+'\\cordova-'+VERSION+'.js')) { !fso.FileExists(ROOT+'\\cordova-'+VERSION+'.js')) {
WScript.Echo("Building jar and js files...");
// update the cordova framework project to a target that exists on this machine // update the cordova framework project to a target that exists on this machine
exec('android.bat update project --target '+TARGET+' --path '+ROOT+'\\framework'); exec('android.bat update project --target '+TARGET+' --path '+ROOT+'\\framework');
// pull down commons codec if necessary // pull down commons codec if necessary
@ -151,12 +162,14 @@ if (!fso.FileExists(ROOT+'\\cordova-'+VERSION+'.jar') &&
} }
// copy in the project template // copy in the project template
WScript.Echo("Copying template files...");
exec('%comspec% /c xcopy '+ ROOT + '\\bin\\templates\\project\\res '+PROJECT_PATH+'\\res\\ /E /Y'); exec('%comspec% /c xcopy '+ ROOT + '\\bin\\templates\\project\\res '+PROJECT_PATH+'\\res\\ /E /Y');
exec('%comspec% /c xcopy '+ ROOT + '\\bin\\templates\\project\\assets '+PROJECT_PATH+'\\assets\\ /E /Y'); exec('%comspec% /c xcopy '+ ROOT + '\\bin\\templates\\project\\assets '+PROJECT_PATH+'\\assets\\ /E /Y');
exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\project\\AndroidManifest.xml ' + PROJECT_PATH + '\\AndroidManifest.xml /Y'); exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\project\\AndroidManifest.xml ' + PROJECT_PATH + '\\AndroidManifest.xml /Y');
exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\project\\Activity.java '+ ACTIVITY_PATH +' /Y'); exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\project\\Activity.java '+ ACTIVITY_PATH +' /Y');
// check if we have the source or the distro files // check if we have the source or the distro files
WScript.Echo("Copying js, jar & config.xml files...");
if(fso.FolderExists(ROOT + '\\framework')) { if(fso.FolderExists(ROOT + '\\framework')) {
exec('%comspec% /c copy '+ROOT+'\\framework\\assets\\www\\cordova-'+VERSION+'.js '+PROJECT_PATH+'\\assets\\www\\cordova-'+VERSION+'.js /Y'); exec('%comspec% /c copy '+ROOT+'\\framework\\assets\\www\\cordova-'+VERSION+'.js '+PROJECT_PATH+'\\assets\\www\\cordova-'+VERSION+'.js /Y');
exec('%comspec% /c copy '+ROOT+'\\framework\\cordova-'+VERSION+'.jar '+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar /Y'); exec('%comspec% /c copy '+ROOT+'\\framework\\cordova-'+VERSION+'.jar '+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar /Y');
@ -174,6 +187,8 @@ if(fso.FolderExists(ROOT + '\\framework')) {
// copy cordova scripts // copy cordova scripts
fso.CreateFolder(PROJECT_PATH + '\\cordova'); fso.CreateFolder(PROJECT_PATH + '\\cordova');
createAppInfoJar();
WScript.Echo("Copying cordova command tools...");
exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\appinfo.jar ' + PROJECT_PATH + '\\cordova\\appinfo.jar /Y'); exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\appinfo.jar ' + PROJECT_PATH + '\\cordova\\appinfo.jar /Y');
exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\cordova.js ' + PROJECT_PATH + '\\cordova\\cordova.js /Y'); exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\cordova.js ' + PROJECT_PATH + '\\cordova\\cordova.js /Y');
exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\cordova.bat ' + PROJECT_PATH + '\\cordova\\cordova.bat /Y'); exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\cordova.bat ' + PROJECT_PATH + '\\cordova\\cordova.bat /Y');
@ -184,6 +199,7 @@ exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\emulate.bat ' + PROJE
exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\BOOM.bat ' + PROJECT_PATH + '\\cordova\\BOOM.bat /Y'); exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\BOOM.bat ' + PROJECT_PATH + '\\cordova\\BOOM.bat /Y');
// interpolate the activity name and package // interpolate the activity name and package
WScript.Echo("Updating AndroidManifest.xml and Main Activity...");
replaceInFile(ACTIVITY_PATH, /__ACTIVITY__/, ACTIVITY); replaceInFile(ACTIVITY_PATH, /__ACTIVITY__/, ACTIVITY);
replaceInFile(ACTIVITY_PATH, /__ID__/, PACKAGE); replaceInFile(ACTIVITY_PATH, /__ID__/, PACKAGE);