Android Project Support - Fix manifest merge task being skipped #58
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