@@ -21,18 +21,64 @@ class SimpleDependencyGraphRenderer : DependencyGraphRenderer {
21
21
resolvedConfigurations : List <ResolvedConfiguration >,
22
22
outputDirectory : File
23
23
) {
24
- val graphOutputFile = File (outputDirectory, " dependency-graph.json" )
25
- val graphJson = JacksonJsonSerializer .serializeToJson(resolvedConfigurations)
26
- graphOutputFile.writeText(graphJson)
27
-
28
- val listOutputFile = File (outputDirectory, " dependency-list.txt" )
29
- val dependencyList = resolvedConfigurations.flatMap { it ->
30
- it.allDependencies.map {
31
- " ${it.coordinates.group} :${it.coordinates.module} :${it.coordinates.version} "
24
+ outputDependencyGraph(outputDirectory, resolvedConfigurations)
25
+ outputDependencyScopes(outputDirectory, resolvedConfigurations)
26
+ outputDependencyList(outputDirectory, resolvedConfigurations)
27
+ }
28
+
29
+ private fun outputDependencyGraph (
30
+ outputDirectory : File ,
31
+ resolvedConfigurations : List <ResolvedConfiguration >
32
+ ) {
33
+ val outputFile = File (outputDirectory, " dependency-graph.json" )
34
+ val jsonContent = JacksonJsonSerializer .serializeToJson(resolvedConfigurations)
35
+ outputFile.writeText(jsonContent)
36
+ }
37
+
38
+ private fun outputDependencyScopes (
39
+ outputDirectory : File ,
40
+ resolvedConfigurations : List <ResolvedConfiguration >
41
+ ) {
42
+ val outputFile = File (outputDirectory, " dependency-scopes.json" )
43
+ val dependencyList: MutableMap <String , MutableSet <SimpleDependencyOrigin >> = mutableMapOf ()
44
+ for (config in resolvedConfigurations) {
45
+ for (dependency in config.allDependencies) {
46
+ val dependencyOrigins = dependencyList.getOrPut(dependency.id) { mutableSetOf () }
47
+ dependencyOrigins.add(
48
+ SimpleDependencyOrigin (
49
+ config.rootOrigin.path,
50
+ config.configurationName
51
+ )
52
+ )
53
+ }
54
+ }
55
+
56
+ val simpleDependencies = dependencyList.map { (id, origins) ->
57
+ SimpleDependency (id, origins.toList())
58
+ }
59
+ val jsonContent = JacksonJsonSerializer .serializeToJson(simpleDependencies)
60
+ outputFile.writeText(jsonContent)
61
+ }
62
+
63
+ private fun outputDependencyList (
64
+ outputDirectory : File ,
65
+ resolvedConfigurations : List <ResolvedConfiguration >
66
+ ) {
67
+ val outputFile = File (outputDirectory, " dependency-list.txt" )
68
+ val dependencyList = resolvedConfigurations.flatMap { config ->
69
+ config.allDependencies.map {
70
+ " ${it.coordinates.group} :${it.coordinates.module} :${it.coordinates.version} ---- ${config.rootOrigin.id} ${config.rootOrigin.path} ${config.configurationName} "
32
71
}
33
72
}.distinct().sorted()
34
73
35
74
val listTxt = dependencyList.joinToString(separator = " \n " )
36
- listOutputFile .writeText(listTxt)
75
+ outputFile .writeText(listTxt)
37
76
}
38
- }
77
+ }
78
+
79
+ data class SimpleDependency (
80
+ val dependency : String ,
81
+ val resolvedBy : List <SimpleDependencyOrigin >
82
+ )
83
+
84
+ data class SimpleDependencyOrigin (val path : String , val configuration : String )
0 commit comments