-
Notifications
You must be signed in to change notification settings - Fork 176
Update projectDependencyGraph to support AGP 4.1 #188
base: master
Are you sure you want to change the base?
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.
if (config.name.toLowerCase().endsWith('implementation')) { | ||
traits.add('style=dotted') | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello ! Any chance getting a fix for this ?
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.