Skip to content

feat: specify appPath and appResourcesPath through project flags #1635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2020
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
15 changes: 13 additions & 2 deletions test-app/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* -PandroidXLegacy=[androidx_legacy_version]
* -PandroidXAppCompat=[androidx_appcompat_version]
* -PandroidXMaterial=[androidx_material_version]
* -PappPath=[app_path]
* -PappResourcesPath=[app_resources_path]
*/


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

if (nsConfig != null && nsConfig.appPath != null) {
if (project.hasProperty("appPath")) {
// when appPath is passed through -PappPath=/path/to/app
// the path could be relative or absolute - either case will work
relativePathToApp = appPath
} else if (nsConfig != null && nsConfig.appPath != null) {
relativePathToApp = nsConfig.appPath
}

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

if (nsConfig != null && nsConfig.appResourcesPath != null) {
if (project.hasProperty("appResourcesPath")) {
// when appResourcesPath is passed through -PappResourcesPath=/path/to/App_Resources
// the path could be relative or absolute - either case will work
relativePathToAppResources = appResourcesPath
absolutePathToAppResources = java.nio.file.Paths.get(USER_PROJECT_ROOT).resolve(relativePathToAppResources).toAbsolutePath()
} else if (nsConfig != null && nsConfig.appResourcesPath != null) {
relativePathToAppResources = nsConfig.appResourcesPath
absolutePathToAppResources = java.nio.file.Paths.get(USER_PROJECT_ROOT).resolve(relativePathToAppResources).toAbsolutePath()
} else {
Expand Down
13 changes: 11 additions & 2 deletions test-app/gradle-helpers/paths.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ ext.getAppPath = { userDir ->
def nsConfigFile = file("$userDir/nsconfig.json")
def nsConfig

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

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

if (nsConfig != null && nsConfig.appResourcesPath != null) {
if (project.hasProperty("appResourcesPath")) {
// when appResourcesPath is passed through -PappResourcesPath=/path/to/App_Resources
// the path could be relative or absolute - either case will work
relativePathToAppResources = ext.appResourcesPath
absolutePathToAppResources = java.nio.file.Paths.get(userDir).resolve(relativePathToAppResources).toAbsolutePath()
} else if (nsConfig != null && nsConfig.appResourcesPath != null) {
relativePathToAppResources = nsConfig.appResourcesPath
absolutePathToAppResources = java.nio.file.Paths.get(userDir).resolve(relativePathToAppResources).toAbsolutePath()
} else {
Expand Down