This repository was archived by the owner on Nov 22, 2024. It is now read-only.
Update projectDependencyGraph to support AGP 4.1#188
Open
ColtonIdle wants to merge 1 commit intoJakeWharton:masterfrom
Open
Update projectDependencyGraph to support AGP 4.1#188ColtonIdle wants to merge 1 commit intoJakeWharton:masterfrom
ColtonIdle wants to merge 1 commit intoJakeWharton:masterfrom
Conversation
AGP 4.1 https://developer.android.com/studio/releases/gradle-plugin?hl=de#library-unit-tests will make every dependency depend on itself which isn't desired.
Comment on lines
59
to
61
| if (config.name.toLowerCase().endsWith('implementation')) { | ||
| traits.add('style=dotted') | ||
| } |
There was a problem hiding this comment.
The if you're introducing also needs to include this other if, otherwise traits won't exist here since it's defined within the scope of the first if (that seems to be the reason the build is failing).
|
|
||
| def graphKey = new Tuple2<Project, Project>(project, dependency) | ||
| def traits = dependencies.computeIfAbsent(graphKey) { new ArrayList<String>() } | ||
| if (!(config.name.toLowerCase().contains('androidtest') || config.name.toLowerCase().contains('unittest'))) { |
There was a problem hiding this comment.
I would say this is doing a bit more than fixing the issue:
- The issue only happens to Android modules, so I think we could choose to do this only when we're dealing with an Android module as well.
- I wonder if instead of skipping it entirely, we could skip only when we've found the Android module depending on itself. I'll play around with this idea here and come back if I can come up with something that makes sense.
There was a problem hiding this comment.
This would do for point 1 (and would also resolve my other comment):
project.configurations.findAll { config ->
// Avoid Android modules pointing to themselves on AGP 4.1+
// https://developer.android.com/studio/releases/gradle-plugin?hl=de#library-unit-tests
!(isAndroid(project) && isTest(config))
}.each { config ->
// ...
}
// ...
static def isAndroid(Project project) {
project.plugins.hasPlugin('com.android.library') || project.plugins.hasPlugin('com.android.application')
}
static def isTest(Configuration config) {
config.name.toLowerCase().contains('androidtest') || config.name.toLowerCase().contains('unittest')
}There was a problem hiding this comment.
Hi, I just upgraded my AGP and now face this self-dependency of each of my Android modules to themselves...
any chances of seeing @tfcporciuncula PR accepted?
There was a problem hiding this comment.
Hello ! Any chance getting a fix for this ?
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
AGP 4.1 https://developer.android.com/studio/releases/gradle-plugin?hl=de#library-unit-tests will make every dependency depend on itself which isn't desired.