Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions gradle/projectDependencyGraph.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ task projectDependencyGraph {
.withType(ProjectDependency)
.collect { it.dependencyProject }
.each { dependency ->
projects.add(project)
projects.add(dependency)
rootProjects.remove(dependency)

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 ?

projects.add(project)
projects.add(dependency)
rootProjects.remove(dependency)

def graphKey = new Tuple2<Project, Project>(project, dependency)
def traits = dependencies.computeIfAbsent(graphKey) { new ArrayList<String>() }
}

if (config.name.toLowerCase().endsWith('implementation')) {
traits.add('style=dotted')
}
Comment on lines 59 to 61
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).

Expand Down