Transfer the code up to the AndroidManifest editing to grunt

This commit is contained in:
Erjan Gavalji
2015-10-19 17:42:41 +03:00
parent 90f3594a60
commit f416908374
2 changed files with 64 additions and 30 deletions

View File

@@ -1,33 +1,73 @@
module.exports = {
run: function(grunt) {
var pathModule = require("path");
var localCfg = {
tnsPath: "tns",
emulatorProcessIdentifier:".*emulator64-x86",
emuAvdName:"Api19",
androidRuntimePath:"/Users/erjan/tns-android.tgz",
outfile:"./TestRunResult.txt",
androidRuntimePath: "/Users/erjan/tns-android.tgz",
androidFrameworkArgument: " --frameworkPath=/Users/erjan/tns-android.tgz",
workingDir:".testsapprun",
testsAppName:"TestsApp",
applicationDir: pathModule.join(".testsapprun", "TestsApp"),
appDir: pathModule.join(".testsapprun", "TestsApp", "app"),
pathToApk:"./platforms/android/build/outputs/apk/TestsApp-debug.apk",
deployedAppName:"org.nativescript.$testsAppName",
mainActivityName:"com.tns.NativeScriptActivity"
mainActivityName:"com.tns.NativeScriptActivity",
pathToCompiledTests: "bin/dist/apps/tests"
}
grunt.initConfig({
clean: {
workingDir: {
src: localCfg.workingDir
},
originalAppDir: {
src: pathModule.join(localCfg.applicationDir, "app") + "/"
}
},
mkdir: {
workingDir: {
options: {
createi: [localCfg.workingDir],
create: [localCfg.workingDir],
mode: 0700
}
}
},
copy: {
testsAppToRunDir: {
src: "**/*.*",
dest: localCfg.appDir,
cwd: localCfg.pathToCompiledTests,
expand: true
},
addAndroidPermissions: {
src: "AndroidManifest.xml",
dest: localCfg.applicationDir + "/platforms/android/src/main/",
cwd: localCfg.applicationDir + "/platforms/android/src/main",
expand: true,
options: {
process: function(content, srcPath) {
var newContent = content;
var internetPermissionFinder = /(<uses-permission[^>]*android\.permission\.INTERNET[^>]*>)/;
if (!/uses-permission[^>]*android\.permission\.ACCESS_NETWORK_STATE/.test(content)) {
newContent = newContent.replace(internetPermissionFinder, "$1\n<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>");
}
if (!/uses-permission[^>]*android\.permission\.ACCESS_FINE_LOCATION/.test(content)) {
newContent = newContent.replace(internetPermissionFinder, "$1\n<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>");
}
return newContent;
}
}
}
},
exec: {
killEmulator: {
cmd: "pkill '" + localCfg.emulatorProcessIdentifier + "'",
@@ -36,11 +76,22 @@ module.exports = {
runTestsApp: {
cmd: "./runtestsapp.sh",
stdout: false
},
startEmulator: {
cmd: "emulator -avd " + localCfg.emuAvdName + " -no-audio -no-window &",
stdout: true
},
createApp: {
cmd: localCfg.tnsPath + " create " + localCfg.testsAppName,
cwd: localCfg.workingDir
},
addAndroidPlatform: {
cmd: "tns platform add android " + localCfg.androidFrameworkArgument,
cwd: localCfg.applicationDir
}
}
});
// grunt.loadNpmTasks("grunt-contrib-copy");
// grunt.loadNpmTasks("grunt-tslint");
// grunt.loadNpmTasks("grunt-multi-dest");
// grunt.loadNpmTasks("grunt-shell");
@@ -49,18 +100,25 @@ module.exports = {
grunt.loadNpmTasks("grunt-exec");
grunt.loadNpmTasks("grunt-mkdir");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.registerTask("testsapp", [
"clean:workingDir",
"mkdir:workingDir",
"exec:killEmulator",
"exec:startEmulator",
// "exec:runTestsApp",
"exec:createApp",
"clean:originalAppDir",
"copy:testsAppToRunDir",
"exec:addAndroidPlatform",
"copy:addAndroidPermissions",
"exec:killEmulator",
"clean:workingDir"
// "exec:killEmulator",
// "clean:workingDir"
]);
}
}

View File

@@ -14,30 +14,6 @@ mainActivityName=com.tns.NativeScriptActivity
# Creating the emulator with:
#android create avd -t "android-21" -n Api21 -b "default/x86"
echo "------------------------------------------------"
echo "Starting the emulator..."
time emulator -avd $emuAvdName -no-audio -no-window &
echo "------------------------------------------------"
echo "Creating the app..."
time tns create $testsAppName
cd $testsAppName
echo "------------------------------------------------"
echo "Removing the original template files..."
time rm app/*.*
echo "------------------------------------------------"
echo "Copying the test app files..."
time cp -r ../../bin/dist/apps/tests/* ./app/
echo "------------------------------------------------"
echo "Adding the android platform..."
time tns platform add android --frameworkPath=$androidRuntimePath
# #DO THE REPLACEMENTS IN THE Info.plist and AndroidManifest.xml
cp /Users/erjan/work/spikes/__DEL__/AndroidManifest.xml platforms/android/src/main/
# GET THIS ONE FROM SOME PLACE...
cp /Volumes/distributions/DailyBuilds/NativeScript/android-widgets/Stable/widgets.jar platforms/android/libs/