Skip to content

Fix include.gradle file generation #294

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Dec 7, 2015

Conversation

rosen-vladimirov
Copy link
Contributor

When include.gradle file is generated, there's a check if the App_Resources directory has been already parsed.
If there's AndroidManifest.xml in the app/App_Resources/Android the global variable appResExists is set to true.
All subsequent plugins will not be added to pluginNames and so will not be added to include.gradle.
For example in case you add AndroidManifest.xml in app/App_Resources and add nativescript-barcodescanner plugin, this is the generated include.gradle on Linux:

android {
    flavorDimensions "NativescriptAppResources",
}

This way the build fails. The reason is that on Linux the file listing is different and App_Resources dir is processed before nativescript-barcodescanner.
The same project will work on Windows, but it is not guarantee that other projects will not fail in the same case.

In order to fix the issue, I've intorduced a new variable in the body of createDefaultIncludeFiles's iteration over files.
It is set to false on each iterration, so if the current dir is not App_Resources, the plugin will be added to pluginNames.
I've kept the code for setting appResExists as it is used on other places in the build.gradle.

When `include.gradle` file is generated, there's a check if the App_Resources directory has been already parsed.
If there's AndroidManifest.xml in the app/App_Resources/Android the global variable appResExists is set to true.
All subsequent plugins will not be added to pluginNames and so will not be added to include.gradle.
For example in case you add AndroidManifest.xml in app/App_Resources and add nativescript-barcodescanner plugin, this is the generated include.gradle on Linux:
```
android {
	flavorDimensions "NativescriptAppResources",
}
```
This way the build fails. The reason is that on Linux the file listing is different and App_Resources dir is processed before nativescript-barcodescanner.
The same project will work on Windows, but it is not guarantee that other projects will not fail in the same case.

In order to fix the issue, I've intorduced a new variable in the body of createDefaultIncludeFiles's iteration over files.
It is set to false on each iterration, so if the current dir is not App_Resources, the plugin will be added to `pluginNames`.
I've kept the code for setting `appResExists` as it is used on other places in the build.gradle.
@ns-bot
Copy link

ns-bot commented Dec 7, 2015

💚

@atanasovg
Copy link
Contributor

💯 ping @Plamen5kov as well

@Plamen5kov
Copy link
Contributor

👍 thank you for the catch @rosen-vladimirov , everything looks great!

Plamen5kov added a commit that referenced this pull request Dec 7, 2015
…-plugins

Fix include.gradle file generation
@Plamen5kov Plamen5kov merged commit 4fd65c4 into master Dec 7, 2015
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/fix-build-gradle-plugins branch December 7, 2015 20:38
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants