Skip to content

Commit b5f1af8

Browse files
author
Nathanael Anderson
authored
Merge pull request #1635 from NativeScript/feat/pathProperties
feat: specify appPath and appResourcesPath through project flags
2 parents b7b6dea + 67dc494 commit b5f1af8

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

test-app/app/build.gradle

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* -PandroidXLegacy=[androidx_legacy_version]
1717
* -PandroidXAppCompat=[androidx_appcompat_version]
1818
* -PandroidXMaterial=[androidx_material_version]
19+
* -PappPath=[app_path]
20+
* -PappResourcesPath=[app_resources_path]
1921
*/
2022

2123

@@ -125,7 +127,11 @@ version of the {N} CLI install a previous version of the runtime package - 'tns
125127
nsConfig = new JsonSlurper().parseText(nsConfigFile.getText("UTF-8"))
126128
}
127129

128-
if (nsConfig != null && nsConfig.appPath != null) {
130+
if (project.hasProperty("appPath")) {
131+
// when appPath is passed through -PappPath=/path/to/app
132+
// the path could be relative or absolute - either case will work
133+
relativePathToApp = appPath
134+
} else if (nsConfig != null && nsConfig.appPath != null) {
129135
relativePathToApp = nsConfig.appPath
130136
}
131137

@@ -144,7 +150,12 @@ version of the {N} CLI install a previous version of the runtime package - 'tns
144150
nsConfig = new JsonSlurper().parseText(nsConfigFile.getText("UTF-8"))
145151
}
146152

147-
if (nsConfig != null && nsConfig.appResourcesPath != null) {
153+
if (project.hasProperty("appResourcesPath")) {
154+
// when appResourcesPath is passed through -PappResourcesPath=/path/to/App_Resources
155+
// the path could be relative or absolute - either case will work
156+
relativePathToAppResources = appResourcesPath
157+
absolutePathToAppResources = java.nio.file.Paths.get(USER_PROJECT_ROOT).resolve(relativePathToAppResources).toAbsolutePath()
158+
} else if (nsConfig != null && nsConfig.appResourcesPath != null) {
148159
relativePathToAppResources = nsConfig.appResourcesPath
149160
absolutePathToAppResources = java.nio.file.Paths.get(USER_PROJECT_ROOT).resolve(relativePathToAppResources).toAbsolutePath()
150161
} else {

test-app/gradle-helpers/paths.gradle

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ ext.getAppPath = { userDir ->
55
def nsConfigFile = file("$userDir/nsconfig.json")
66
def nsConfig
77

8-
if (nsConfigFile.exists()) {
8+
if (project.hasProperty("appPath")) {
9+
// when appPath is passed through -PappPath=/path/to/app
10+
// the path could be relative or absolute - either case will work
11+
relativePathToApp = appPath
12+
} else if (nsConfigFile.exists()) {
913
nsConfig = new JsonSlurper().parseText(nsConfigFile.getText("UTF-8"))
1014
}
1115

@@ -26,7 +30,12 @@ ext.getAppResourcesPath = { userDir ->
2630
nsConfig = new JsonSlurper().parseText(nsConfigFile.getText("UTF-8"))
2731
}
2832

29-
if (nsConfig != null && nsConfig.appResourcesPath != null) {
33+
if (project.hasProperty("appResourcesPath")) {
34+
// when appResourcesPath is passed through -PappResourcesPath=/path/to/App_Resources
35+
// the path could be relative or absolute - either case will work
36+
relativePathToAppResources = ext.appResourcesPath
37+
absolutePathToAppResources = java.nio.file.Paths.get(userDir).resolve(relativePathToAppResources).toAbsolutePath()
38+
} else if (nsConfig != null && nsConfig.appResourcesPath != null) {
3039
relativePathToAppResources = nsConfig.appResourcesPath
3140
absolutePathToAppResources = java.nio.file.Paths.get(userDir).resolve(relativePathToAppResources).toAbsolutePath()
3241
} else {

0 commit comments

Comments
 (0)