Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
==

Expand Down
57 changes: 28 additions & 29 deletions build-artifacts/project-template-gradle/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
49 changes: 49 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down