Skip to content

Commit c25a0e5

Browse files
authored
Merge pull request #1369 from NativeScript/trifonov/use-v8-symbols
check for useV8Symbols setting in package.json
2 parents 0f8e7b6 + c22fcbe commit c25a0e5

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

test-app/app/build.gradle

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,8 @@ version of the {N} CLI install a previous version of the runtime package - 'tns
8989
project.ext.PLATFORMS_ANDROID = "platforms/android"
9090
project.ext.USER_PROJECT_ROOT = "$rootDir/../.."
9191

92-
project.ext.getAppResourcesPath = { ->
92+
project.ext.getAppPath = { ->
9393
def relativePathToApp = "app"
94-
def relativePathToAppResources
95-
def absolutePathToAppResources
9694
def nsConfigFile = file("$USER_PROJECT_ROOT/nsconfig.json")
9795
def nsConfig
9896

@@ -104,14 +102,28 @@ version of the {N} CLI install a previous version of the runtime package - 'tns
104102
relativePathToApp = nsConfig.appPath
105103
}
106104

105+
project.ext.appPath = java.nio.file.Paths.get(USER_PROJECT_ROOT).resolve(relativePathToApp).toAbsolutePath()
106+
107+
return project.ext.appPath
108+
}
109+
110+
project.ext.getAppResourcesPath = { ->
111+
def relativePathToAppResources
112+
def absolutePathToAppResources
113+
def nsConfigFile = file("$USER_PROJECT_ROOT/nsconfig.json")
114+
def nsConfig
115+
116+
if (nsConfigFile.exists()) {
117+
nsConfig = new JsonSlurper().parseText(nsConfigFile.getText("UTF-8"))
118+
}
119+
107120
if (nsConfig != null && nsConfig.appResourcesPath != null) {
108121
relativePathToAppResources = nsConfig.appResourcesPath
122+
absolutePathToAppResources = java.nio.file.Paths.get(USER_PROJECT_ROOT).resolve(relativePathToAppResources).toAbsolutePath()
109123
} else {
110-
relativePathToAppResources = "$relativePathToApp/App_Resources"
124+
absolutePathToAppResources = "${getAppPath()}/App_Resources"
111125
}
112126

113-
absolutePathToAppResources = java.nio.file.Paths.get(USER_PROJECT_ROOT).resolve(relativePathToAppResources).toAbsolutePath()
114-
115127
project.ext.appResourcesPath = absolutePathToAppResources
116128

117129
return absolutePathToAppResources
@@ -188,7 +200,7 @@ def getAppIdentifier = { packageJsonMap ->
188200

189201
def setAppIdentifier = { ->
190202
println "\t + setting applicationId"
191-
File packageJsonFile = new File("$rootDir/../../package.json")
203+
File packageJsonFile = new File("$USER_PROJECT_ROOT/$PACKAGE_JSON")
192204

193205
if (packageJsonFile.exists()) {
194206
def content = packageJsonFile.getText("UTF-8")
@@ -326,11 +338,24 @@ dependencies {
326338
implementation "com.android.support:appcompat-v7:$supportVer"
327339
implementation "com.android.support:design:$supportVer"
328340
}
329-
def useV8Symbols = nativescriptDependencies.any {
330-
def packageJsonPath = file("$rootDir/${it.directory}/$PACKAGE_JSON")
331-
def packageJson = new JsonSlurper().parseText(packageJsonPath.text)
332-
return packageJson.nativescript.useV8Symbols
341+
342+
def useV8Symbols = false
343+
344+
def appPackageJsonFile = file("${getAppPath()}/$PACKAGE_JSON")
345+
if (appPackageJsonFile.exists()) {
346+
def appPackageJson = new JsonSlurper().parseText(appPackageJsonFile.text)
347+
useV8Symbols = appPackageJson.android && appPackageJson.android.useV8Symbols
333348
}
349+
350+
if (!useV8Symbols) {
351+
// check whether any of the dependencies require v8 symbols
352+
useV8Symbols = nativescriptDependencies.any {
353+
def packageJsonFile = file("$rootDir/${it.directory}/$PACKAGE_JSON")
354+
def packageJson = new JsonSlurper().parseText(packageJsonFile.text)
355+
return packageJson.nativescript && packageJson.nativescript.useV8Symbols
356+
}
357+
}
358+
334359
if (!externalRuntimeExists) {
335360
def runtime = "nativescript-optimized-with-inspector"
336361

@@ -539,7 +564,7 @@ afterEvaluate { project ->
539564
// It mattered only when we were extracting JARs from AARs.
540565
// To try it simply remove the following comments.
541566
// workerExecutor.submit(EmptyRunnable.class) {
542-
explodeAar(jar, outputDir)
567+
explodeAar(jar, outputDir)
543568
// }
544569
}
545570
}

0 commit comments

Comments
 (0)