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.application
gradle plugin adds tasks and steps up it's depencies on theproject.afterEvaluate
event as well. The existing logic on whether to apply rules or not is done by checkingconfig.allDependencies.isEmpty()
. This will be empty for theprocessDebugResources
task for example.processReleaseResources
is executed when calling the standardbuild
task on an Android project.Note that
./gradlew app:dependencies --configuration compile
works fine, however tasks that do manifest merging fail. For example if we use mismatched versions of thecom.android.support
group in the main app'sbuild.gradle
but try to create an alignment rule to sync them it won't be applied to theprocessReleaseResources
task 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.afterTask
when 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.onExecute
event.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.onExecute
can be delayed soconfig.allDependencies
are fully resolved by any other gradle plugins."Skipping dependency rules for configuration \':compile\' - No dependencies are configured"
test