Skip to content

Commit 7040468

Browse files
authored
Merge pull request #937 from NativeScript/pete/fix-include-gradle-flavor-generation
fix include gradle flavor generation
2 parents 34cf539 + b6a99cc commit 7040468

File tree

4 files changed

+85
-30
lines changed

4 files changed

+85
-30
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
3.4.2
2+
==
3+
4+
## Bug Fixes
5+
6+
- [fix include gradle flavor generation for plugins with incomplete include.gradle scripts (#937)](https://github.com/NativeScript/android-runtime/pull/937)
7+
18
3.4.1
29
==
310

build-artifacts/project-template-gradle/app/build.gradle

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -349,43 +349,42 @@ static def sanitizeDimensionName(str) {
349349
}
350350

351351
static def modifyProductFlavorInContent(content, dimension, flavor) {
352-
def indexStart = content.indexOf("productFlavors");
353-
def index = indexStart + "productFlavors".length();
354-
def indexEnd = -1;
355-
def nestedOpenBracketsCount = 0;
356-
357-
while (index < content.length())
358-
{
359-
// print content[index];
360-
if (content[index] == "}")
361-
{
362-
nestedOpenBracketsCount--;
363-
364-
if (nestedOpenBracketsCount == 0)
365-
{
366-
indexEnd = index;
367-
break;
352+
def PRODUCT_FLAVORS = "productFlavors"
353+
def indexStart = content.indexOf(PRODUCT_FLAVORS)
354+
def index = indexStart + PRODUCT_FLAVORS.length()
355+
def indexEnd = -1
356+
def nestedOpenBracketsCount = 0
357+
358+
if (indexStart != -1) {
359+
// get the index of the closing bracket of the productFlavors { } scope
360+
while (index < content.length()) {
361+
// print content[index];
362+
if (content[index] == "}") {
363+
nestedOpenBracketsCount--
364+
365+
if (nestedOpenBracketsCount == 0) {
366+
indexEnd = index
367+
break
368+
}
369+
} else if (content[index] == "{") {
370+
nestedOpenBracketsCount++
368371
}
369-
}
370-
else if (content[index] == "{")
371-
{
372-
nestedOpenBracketsCount++;
373-
}
374372

375-
index++;
373+
index++
374+
}
376375
}
377376

378-
if (indexEnd != -1)
379-
{
377+
378+
if (indexEnd != -1) {
379+
// replace the productFlavor dimension with a shorter one - F0, F1, F2, etc.
380380
// full content of productFlavors { ... } -> the substring is parenthesis to parenthesis -> { ... }
381-
def oldProductFlavorsText = content.substring(indexStart, indexEnd + 1);
381+
def oldProductFlavorsText = content.substring(indexStart, indexEnd + 1)
382382

383383
def newProductFlavorsContent = updateProductFlavorsContent(flavor, dimension, oldProductFlavorsText);
384384

385-
return content.replace(oldProductFlavorsText, newProductFlavorsContent);
386-
}
387-
else
388-
{
385+
return content.replace(oldProductFlavorsText, newProductFlavorsContent)
386+
} else {
387+
// create a productFlavor dimension - F0, F1, F2, etc.
389388
def androidContentExists = content.indexOf("android {") != -1;
390389
def newProductFlavorsContent = createProductFlavorsContent(flavor, dimension, !androidContentExists);
391390

build.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
###############################################################################################
2+
# Android Runtime build script for CI.
3+
# This file is used by the CI only and it's not meant for regular development.
4+
###############################################################################################
5+
6+
echo "Ensure adb is in PATH"
7+
export PATH=$ANDROID_HOME/platform-tools:$PATH
8+
adb version
9+
10+
echo "Update submodule"
11+
git submodule update --init
12+
13+
echo "Cleanup old build and test artefacts"
14+
rm -rf dist/*
15+
rm -rf consoleLog.txt
16+
rm -rf test-app/dist/android_unit_test_results.xml
17+
rm -rf binding-generator/build/test-results/*.xml
18+
rm -rf android-static-binding-generator/project/staticbindinggenerator/build/test-results/*.xml
19+
20+
echo "Running android static binding generator tests"
21+
cwd=$(pwd)
22+
cd android-static-binding-generator/project/staticbindinggenerator
23+
./gradlew test
24+
cd $cwd
25+
26+
echo "Stopping running emulators if any"
27+
for KILLPID in `ps ax | grep 'emulator' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done
28+
for KILLPID in `ps ax | grep 'qemu' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done
29+
for KILLPID in `ps ax | grep 'adb' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done
30+
31+
echo "Start emulator"
32+
$ANDROID_HOME/tools/emulator -avd Emulator-Api19-Default -wipe-data -gpu on &
33+
34+
echo "Building Android Runtime with paramerter packageVersion: $PACKAGE_VERSION and commit: $GIT_COMMIT"
35+
./gradlew -PpackageVersion=$PACKAGE_VERSION -PgitCommitVersion=$GIT_COMMIT
36+
37+
echo "Run Android Runtime unit tests"
38+
cp dist/tns-android-*.tgz dist/tns-android.tgz
39+
$ANDROID_HOME/platform-tools/adb devices
40+
$ANDROID_HOME/platform-tools/adb -e logcat -c
41+
$ANDROID_HOME/platform-tools/adb -e logcat > consoleLog.txt &
42+
cd test-app
43+
./gradlew runtest --rerun-tasks
44+
45+
echo "Stopping running emulators"
46+
for KILLPID in `ps ax | grep 'emulator' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done || true
47+
for KILLPID in `ps ax | grep 'qemu' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done || true
48+
for KILLPID in `ps ax | grep 'adb' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID &> /dev/null; done || true
49+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tns-android",
33
"description": "NativeScript Runtime for Android",
4-
"version": "3.4.1",
4+
"version": "3.4.2",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/NativeScript/android-runtime.git"

0 commit comments

Comments
 (0)