From 7a3802f8c365991078afc7280b23ecb472fbf514 Mon Sep 17 00:00:00 2001 From: Tony Robalik Date: Wed, 2 Oct 2024 15:26:10 -0700 Subject: [PATCH] fix: include project description json at both external and internal coordinates. --- .../tasks/SynthesizeDependenciesTask.kt | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/autonomousapps/tasks/SynthesizeDependenciesTask.kt b/src/main/kotlin/com/autonomousapps/tasks/SynthesizeDependenciesTask.kt index 4e38e5bcf..7e8bc827c 100644 --- a/src/main/kotlin/com/autonomousapps/tasks/SynthesizeDependenciesTask.kt +++ b/src/main/kotlin/com/autonomousapps/tasks/SynthesizeDependenciesTask.kt @@ -2,7 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 package com.autonomousapps.tasks -import com.autonomousapps.internal.utils.* +import com.autonomousapps.internal.utils.bufferWriteJson +import com.autonomousapps.internal.utils.fromJson +import com.autonomousapps.internal.utils.fromJsonSet +import com.autonomousapps.internal.utils.fromNullableJsonSet import com.autonomousapps.model.* import com.autonomousapps.model.intermediates.* import com.autonomousapps.services.InMemoryCache @@ -158,13 +161,17 @@ abstract class SynthesizeDependenciesTask @Inject constructor( dependencies.forEach { dependency -> // Do not add dependencies that are already known again val coordinatesAlreadyKnown = builders.values.any { - it.coordinates == dependency || ( - // If the dependency is pointing at a project, there might already be an artifact - // stored under matching IncludedBuildCoordinates. - it.coordinates is IncludedBuildCoordinates - && dependency.identifier == it.coordinates.resolvedProject.identifier - && dependency.gradleVariantIdentification.variantMatches(it.coordinates.resolvedProject) - ) + it.coordinates == dependency + // TODO(tsr): including the following in the check is too aggressive and can lead to failures in the + // ProjectVariant::dependencies function when looking for a file. This can happen, I think, when a dependency + // is specified as an external dependency but ends up getting resolved as a local project dependency instead. + // The simplest thing is to include the json file for this dep twice. Wastes some disk space (etc), but + // solves the problem. I doubt this is the best solution to the problem. + // If the dependency is pointing at a project, there might already be an artifact + // stored under matching IncludedBuildCoordinates. + // || (it.coordinates is IncludedBuildCoordinates + // && dependency.identifier == it.coordinates.resolvedProject.identifier + // && dependency.gradleVariantIdentification.variantMatches(it.coordinates.resolvedProject)) } if (!coordinatesAlreadyKnown) { builders.merge(