diff --git a/CHANGELOG.md b/CHANGELOG.md index 138ef3f71..9e2df4ae8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +3.4.2 +== + +## Bug Fixes + + - [fix include gradle flavor generation for plugins with incomplete include.gradle scripts (#937)](https://github.com/NativeScript/android-runtime/pull/937) + 3.4.1 == diff --git a/build-artifacts/project-template-gradle/app/build.gradle b/build-artifacts/project-template-gradle/app/build.gradle index 8e8658018..ab78cb43a 100644 --- a/build-artifacts/project-template-gradle/app/build.gradle +++ b/build-artifacts/project-template-gradle/app/build.gradle @@ -349,43 +349,42 @@ static def sanitizeDimensionName(str) { } static def modifyProductFlavorInContent(content, dimension, flavor) { - def indexStart = content.indexOf("productFlavors"); - def index = indexStart + "productFlavors".length(); - def indexEnd = -1; - def nestedOpenBracketsCount = 0; - - while (index < content.length()) - { - // print content[index]; - if (content[index] == "}") - { - nestedOpenBracketsCount--; - - if (nestedOpenBracketsCount == 0) - { - indexEnd = index; - break; + def PRODUCT_FLAVORS = "productFlavors" + def indexStart = content.indexOf(PRODUCT_FLAVORS) + def index = indexStart + PRODUCT_FLAVORS.length() + def indexEnd = -1 + def nestedOpenBracketsCount = 0 + + if (indexStart != -1) { + // get the index of the closing bracket of the productFlavors { } scope + while (index < content.length()) { + // print content[index]; + if (content[index] == "}") { + nestedOpenBracketsCount-- + + if (nestedOpenBracketsCount == 0) { + indexEnd = index + break + } + } else if (content[index] == "{") { + nestedOpenBracketsCount++ } - } - else if (content[index] == "{") - { - nestedOpenBracketsCount++; - } - index++; + index++ + } } - if (indexEnd != -1) - { + + if (indexEnd != -1) { + // replace the productFlavor dimension with a shorter one - F0, F1, F2, etc. // full content of productFlavors { ... } -> the substring is parenthesis to parenthesis -> { ... } - def oldProductFlavorsText = content.substring(indexStart, indexEnd + 1); + def oldProductFlavorsText = content.substring(indexStart, indexEnd + 1) def newProductFlavorsContent = updateProductFlavorsContent(flavor, dimension, oldProductFlavorsText); - return content.replace(oldProductFlavorsText, newProductFlavorsContent); - } - else - { + return content.replace(oldProductFlavorsText, newProductFlavorsContent) + } else { + // create a productFlavor dimension - F0, F1, F2, etc. def androidContentExists = content.indexOf("android {") != -1; def newProductFlavorsContent = createProductFlavorsContent(flavor, dimension, !androidContentExists); diff --git a/build.sh b/build.sh new file mode 100755 index 000000000..0ec18bb4d --- /dev/null +++ b/build.sh @@ -0,0 +1,49 @@ +############################################################################################### +# Android Runtime build script for CI. +# This file is used by the CI only and it's not meant for regular development. +############################################################################################### + +echo "Ensure adb is in PATH" +export PATH=$ANDROID_HOME/platform-tools:$PATH +adb version + +echo "Update submodule" +git submodule update --init + +echo "Cleanup old build and test artefacts" +rm -rf dist/* +rm -rf consoleLog.txt +rm -rf test-app/dist/android_unit_test_results.xml +rm -rf binding-generator/build/test-results/*.xml +rm -rf android-static-binding-generator/project/staticbindinggenerator/build/test-results/*.xml + +echo "Running android static binding generator tests" +cwd=$(pwd) +cd android-static-binding-generator/project/staticbindinggenerator +./gradlew test +cd $cwd + +echo "Stopping running emulators if any" +for KILLPID in `ps ax | grep 'emulator' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done +for KILLPID in `ps ax | grep 'qemu' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done +for KILLPID in `ps ax | grep 'adb' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done + +echo "Start emulator" +$ANDROID_HOME/tools/emulator -avd Emulator-Api19-Default -wipe-data -gpu on & + +echo "Building Android Runtime with paramerter packageVersion: $PACKAGE_VERSION and commit: $GIT_COMMIT" +./gradlew -PpackageVersion=$PACKAGE_VERSION -PgitCommitVersion=$GIT_COMMIT + +echo "Run Android Runtime unit tests" +cp dist/tns-android-*.tgz dist/tns-android.tgz +$ANDROID_HOME/platform-tools/adb devices +$ANDROID_HOME/platform-tools/adb -e logcat -c +$ANDROID_HOME/platform-tools/adb -e logcat > consoleLog.txt & +cd test-app +./gradlew runtest --rerun-tasks + +echo "Stopping running emulators" +for KILLPID in `ps ax | grep 'emulator' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done || true +for KILLPID in `ps ax | grep 'qemu' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done || true +for KILLPID in `ps ax | grep 'adb' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID &> /dev/null; done || true + diff --git a/package.json b/package.json index 5135eb9e4..123a1dfc7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tns-android", "description": "NativeScript Runtime for Android", - "version": "3.4.1", + "version": "3.4.2", "repository": { "type": "git", "url": "https://github.com/NativeScript/android-runtime.git"