forked from github/cordova-android
checking if project exits
This commit is contained in:
parent
234ee63859
commit
cbe1216bc2
@ -52,7 +52,6 @@ function exec(s, output) {
|
|||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
// Cleanup
|
// Cleanup
|
||||||
WScript.Echo('Cleaning up...');
|
|
||||||
if(fso.FileExists(ROOT + '\\framework\\libs\\commons-codec-1.6.jar')) {
|
if(fso.FileExists(ROOT + '\\framework\\libs\\commons-codec-1.6.jar')) {
|
||||||
fso.DeleteFile(ROOT + '\\framework\\libs\\commons-codec-1.6.jar');
|
fso.DeleteFile(ROOT + '\\framework\\libs\\commons-codec-1.6.jar');
|
||||||
fso.DeleteFolder(ROOT + '\\framework\\libs', true);
|
fso.DeleteFolder(ROOT + '\\framework\\libs', true);
|
||||||
@ -65,33 +64,8 @@ function cleanup() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var args = WScript.Arguments, PROJECT_PATH="example",
|
function downloadCommonsCodec() {
|
||||||
PACKAGE="org.apache.cordova.example", ACTIVITY="cordovaExample",
|
if (!fso.FileExists(ROOT + '\\framework\\libs\\commons-codec-1.6.jar')) {
|
||||||
shell=WScript.CreateObject("WScript.Shell");
|
|
||||||
|
|
||||||
// working dir
|
|
||||||
var ROOT = WScript.ScriptFullName.split('\\bin\\create.js').join('');
|
|
||||||
|
|
||||||
if (args.Count() == 3) {
|
|
||||||
PROJECT_PATH=args(0);
|
|
||||||
PACKAGE=args(1);
|
|
||||||
ACTIVITY=args(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
var PACKAGE_AS_PATH=PACKAGE.replace(/\./g, '\\');
|
|
||||||
var ACTIVITY_PATH=PROJECT_PATH+'\\src\\'+PACKAGE_AS_PATH+'\\'+ACTIVITY+'.java';
|
|
||||||
var MANIFEST_PATH=PROJECT_PATH+'\\AndroidManifest.xml';
|
|
||||||
var TARGET=shell.Exec('android.bat list targets').StdOut.ReadAll().match(/id:\s([0-9]).*/)[1];
|
|
||||||
var VERSION=read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,'');
|
|
||||||
|
|
||||||
// create the project
|
|
||||||
exec('android.bat create project --target '+TARGET+' --path '+PROJECT_PATH+' --package '+PACKAGE+' --activity '+ACTIVITY);
|
|
||||||
|
|
||||||
// update the cordova framework project to a target that exists on this machine
|
|
||||||
exec('android.bat update project --target '+TARGET+' --path '+ROOT+'\\framework');
|
|
||||||
|
|
||||||
// pull down commons codec if necessary
|
|
||||||
if (!fso.FileExists(ROOT + '\\framework\\libs\\commons-codec-1.6.jar')) {
|
|
||||||
// We need the .jar
|
// We need the .jar
|
||||||
var url = 'http://mirror.symnds.com/software/Apache//commons/codec/binaries/commons-codec-1.6-bin.zip';
|
var url = 'http://mirror.symnds.com/software/Apache//commons/codec/binaries/commons-codec-1.6-bin.zip';
|
||||||
var libsPath = ROOT + '\\framework\\libs';
|
var libsPath = ROOT + '\\framework\\libs';
|
||||||
@ -127,10 +101,42 @@ if (!fso.FileExists(ROOT + '\\framework\\libs\\commons-codec-1.6.jar')) {
|
|||||||
// Clean up
|
// Clean up
|
||||||
fso.DeleteFile(ROOT + '\\framework\\libs\\commons-codec-1.6-bin.zip');
|
fso.DeleteFile(ROOT + '\\framework\\libs\\commons-codec-1.6-bin.zip');
|
||||||
fso.DeleteFolder(ROOT + '\\framework\\libs\\commons-codec-1.6', true);
|
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
|
var args = WScript.Arguments, PROJECT_PATH="example",
|
||||||
// update your android tools or install an additional Android platform version
|
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) {
|
||||||
|
PROJECT_PATH=args(0);
|
||||||
|
PACKAGE=args(1);
|
||||||
|
ACTIVITY=args(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fso.FolderExists(PROJECT_PATH)) {
|
||||||
|
WScript.Echo("Project already exists!");
|
||||||
|
WScript.Quit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
var PACKAGE_AS_PATH=PACKAGE.replace(/\./g, '\\');
|
||||||
|
var ACTIVITY_PATH=PROJECT_PATH+'\\src\\'+PACKAGE_AS_PATH+'\\'+ACTIVITY+'.java';
|
||||||
|
var MANIFEST_PATH=PROJECT_PATH+'\\AndroidManifest.xml';
|
||||||
|
var TARGET=shell.Exec('android.bat list targets').StdOut.ReadAll().match(/id:\s([0-9]).*/)[1];
|
||||||
|
var VERSION=read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,'');
|
||||||
|
|
||||||
|
// create the project
|
||||||
|
exec('android.bat create project --target '+TARGET+' --path '+PROJECT_PATH+' --package '+PACKAGE+' --activity '+ACTIVITY);
|
||||||
|
|
||||||
|
// update the cordova framework project to a target that exists on this machine
|
||||||
|
exec('android.bat update project --target '+TARGET+' --path '+ROOT+'\\framework');
|
||||||
|
|
||||||
|
// pull down commons codec if necessary
|
||||||
|
downloadCommonsCodec();
|
||||||
|
|
||||||
exec('ant.bat -f '+ ROOT +'\\framework\\build.xml jar');
|
exec('ant.bat -f '+ ROOT +'\\framework\\build.xml jar');
|
||||||
|
|
||||||
// copy in the project template
|
// copy in the project template
|
||||||
|
Loading…
x
Reference in New Issue
Block a user