@@ -34,34 +34,71 @@ data class OverShotDependencies(
34
34
suspend fun get (configurationName : ConfigurationName ): List <OverShotDependencyFinding > {
35
35
return delegate.getOrPut(configurationName) {
36
36
37
+ fun log (msg : String ) {
38
+ if (project.path == " :lib2" ) {
39
+ println (msg)
40
+ }
41
+ }
42
+
37
43
project.unusedDependencies()
38
44
.get(configurationName)
39
45
.flatMap { unused ->
40
46
47
+ log(
48
+ " unused\n\n $unused \n " +
49
+ " ~~cpd~~" +
50
+ " ${unused.cpd()} \n " +
51
+ " _____________"
52
+ )
53
+
41
54
val configSuffix = unused.configurationName
42
- .nameWithoutSourceSet()
43
- . takeIf { ! it.equals( ConfigurationName .api.value, ignoreCase = true ) }
55
+ .takeIf { ! it.isApi() }
56
+ ?.nameWithoutSourceSet()
44
57
? : ConfigurationName .implementation.value
45
58
46
- val allUsedByConfigName = project.sourceSets
47
- .keys
48
- .filterNot { it == unused.configurationName.toSourceSetName() }
59
+ log(" suffix --> $configSuffix " )
60
+
61
+ val allUsedByConfigName = unused.configurationName
62
+ .toSourceSetName()
63
+ .withDownStream(project)
49
64
.mapNotNull { sourceSetName ->
50
65
51
66
sourceSetName.javaConfigurationNames()
52
- .filterNot { it == unused.configurationName }
67
+ .asSequence()
53
68
// check the same config as the unused configuration first.
54
- // for instance, if `api` is unused, check `debugApi`, `testApi `, etc.
69
+ // for instance, if `api` is unused, check `debugApi`, `releaseApi `, etc.
55
70
.sortedByDescending {
56
71
it.nameWithoutSourceSet().equals(configSuffix, ignoreCase = true )
57
72
}
58
- .firstNotNullOfOrNull { configName ->
73
+ .flatMap { configName ->
74
+ setOf (
75
+ configName to unused.cpd().isTestFixture,
76
+ configName to false
77
+ )
78
+ }
79
+ .map { (configName, isTestFixture) ->
80
+
59
81
ConfiguredProjectDependency (
60
82
configurationName = configName,
61
83
project = unused.dependencyProject,
62
- isTestFixture = unused.cpd(). isTestFixture
84
+ isTestFixture = isTestFixture
63
85
)
64
- .takeIf { project.uses(it) }
86
+ }
87
+ .filterNot {
88
+ it.isTestFixture == unused.cpd().isTestFixture &&
89
+ it.configurationName
90
+ .toSourceSetName() == unused.cpd()
91
+ .configurationName
92
+ .toSourceSetName()
93
+ }
94
+ .firstNotNullOfOrNull { cpd ->
95
+
96
+ cpd.takeIf {
97
+
98
+ log(" ~~~~ checking cpd --> $it ============= ${project.uses(it)} " )
99
+
100
+ project.uses(it)
101
+ }
65
102
}
66
103
}
67
104
.groupBy { it.configurationName }
@@ -91,7 +128,9 @@ data class OverShotDependencies(
91
128
newDependency = cpp,
92
129
oldDependency = cpp.copy(configurationName = originalConfigurationName),
93
130
configurationName = cpp.configurationName
94
- )
131
+ ).also {
132
+ log(" ** final overshot **\n $it \n ++++++++++++++++++" )
133
+ }
95
134
}
96
135
.sortedBy { it.dependencyProject }
97
136
.distinctBy { it.dependencyProject }
0 commit comments