Skip to content

Commit c8c776e

Browse files
committed
Log resolved dependencies and associated configuration
Info-level logging will make it easier to determine the source of a dependency that appears in the graph. Fixes #113
1 parent a438b65 commit c8c776e

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

plugin/src/main/kotlin/org/gradle/dependencygraph/extractor/DependencyExtractor.kt

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,10 @@ abstract class DependencyExtractor :
163163
val configurationName = details.configurationName
164164

165165
if (!configurationFilter.include(rootPath, configurationName)) {
166-
LOGGER.debug("Ignoring resolved configuration: $rootPath - $configurationName")
166+
LOGGER.info("Excluding resolved configuration from dependency graph: $rootPath - $configurationName")
167167
return
168168
}
169+
LOGGER.info("Including resolved configuration in dependency graph: $rootPath - $configurationName")
169170

170171
val scope = dependencyScope(rootPath, configurationName)
171172

@@ -293,7 +294,12 @@ abstract class DependencyExtractor :
293294

294295
private fun createRenderer(): DependencyGraphRenderer {
295296
LOGGER.lifecycle("Constructing renderer: ${getRendererClassName()}")
296-
return Class.forName(getRendererClassName()).getDeclaredConstructor().newInstance() as DependencyGraphRenderer
297+
val dependencyGraphRenderer =
298+
Class.forName(getRendererClassName()).getDeclaredConstructor().newInstance() as DependencyGraphRenderer
299+
if (LOGGER.isInfoEnabled) {
300+
return LoggingDependencyGraphRenderer(dependencyGraphRenderer)
301+
}
302+
return dependencyGraphRenderer
297303
}
298304

299305
private fun getOutputDir(): File {
@@ -334,6 +340,22 @@ abstract class DependencyExtractor :
334340
}
335341
}
336342

343+
private class LoggingDependencyGraphRenderer(private val delegate: DependencyGraphRenderer) : DependencyGraphRenderer {
344+
override fun outputDependencyGraph(
345+
pluginParameters: PluginParameters,
346+
buildLayout: BuildLayout,
347+
resolvedConfigurations: List<ResolvedConfiguration>,
348+
outputDirectory: File
349+
) {
350+
for (configuration in resolvedConfigurations) {
351+
for (dependency in configuration.allDependencies) {
352+
LOGGER.info("Detected dependency '${dependency.id}': project = '${configuration.rootOrigin.path}', configuration = '${configuration.configurationName}'")
353+
}
354+
}
355+
delegate.outputDependencyGraph(pluginParameters, buildLayout, resolvedConfigurations, outputDirectory)
356+
}
357+
}
358+
337359
companion object {
338360
private val LOGGER = Logging.getLogger(DependencyExtractor::class.java)
339361
}

0 commit comments

Comments
 (0)