Android Project Support - Fix manifest merge task being skipped #58
Open
jkasten2 wants to merge 1 commit intonebula-plugins:mainfrom
Open
Android Project Support - Fix manifest merge task being skipped #58jkasten2 wants to merge 1 commit intonebula-plugins:mainfrom
jkasten2 wants to merge 1 commit intonebula-plugins:mainfrom
Conversation
b36f602 to
084ece7
Compare
* Fixed issue where rules were not applied to all Android tasks - Rules where not applying as android plugin had not added it's task dependencies yet - This was due to gradle plugin 'com.android.application' also replying on project.afterEvaluate - Rules are now applied on project.gradle.taskGraph.afterTask instead
084ece7 to
5a4e3e1
Compare
Author
|
@DanielThomas I just completed this pull request, could you give it a review? This plugin solves a number of common gradle dependency issues and would be a great help to Android developers if they could use it as well! Specifically around having group alignment for the Android Support Library and Google Play Services Library since each includes a number of modules per group. |
43a92a1 to
80e3988
Compare
7024b8e to
e69b22d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
This plugin is not compatible with Android projects as the
com.android.applicationgradle plugin adds tasks and steps up it's depencies on theproject.afterEvaluateevent as well. The existing logic on whether to apply rules or not is done by checkingconfig.allDependencies.isEmpty(). This will be empty for theprocessDebugResourcestask for example.processReleaseResourcesis executed when calling the standardbuildtask on an Android project.Note that
./gradlew app:dependencies --configuration compileworks fine, however tasks that do manifest merging fail. For example if we use mismatched versions of thecom.android.supportgroup in the main app'sbuild.gradlebut try to create an alignment rule to sync them it won't be applied to theprocessReleaseResourcestask and following error will throw:The following test reproduces this issue.
https://github.com/nebula-plugins/gradle-resolution-rules-plugin/pull/58/files#diff-c71d74290a4498733d4ad203fc844abaR393
Solutions
Solution 1
This is the one that is implemented in this pull.
Add a delay fallback on the
project.gradle.taskGraph.afterTaskwhen the rules are applied. In my testing I found that this is run after the Android plugin sets up the dependencies on it's tasks. Since this doesn't pass all existing tests with the delayed event on it's own we need to keep theproject.onExecuteevent.Solution 2
Another solution would be to simply remove the
config.allDependencies.isEmpty()check. However it looks like this was put into place due to performance reasons.TODO
project.onExecutecan be delayed soconfig.allDependenciesare fully resolved by any other gradle plugins."Skipping dependency rules for configuration \':compile\' - No dependencies are configured"test