Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Update projectDependencyGraph to support AGP 4.1 #188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ColtonIdle
Copy link

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')
}
Copy link

@tfcporciuncula tfcporciuncula Oct 28, 2020

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'))) {
Copy link

@tfcporciuncula tfcporciuncula Oct 28, 2020

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:

  1. 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.
  2. 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.

Copy link

@tfcporciuncula tfcporciuncula Oct 28, 2020

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')
}

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?

Copy link

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 ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants