Skip to content

Commit

Permalink
Normalize label (#968)
Browse files Browse the repository at this point in the history
* Normalize label

Normalize the label from the jar the same way the unused_deps tool. See https://github.com/bazelbuild/buildtools/blob/master/unused_deps/unused_deps.go#L181

* Fix identation

* Update JdepsMerger.kt
  • Loading branch information
mauriciogg authored May 23, 2023
1 parent 883a27f commit ecfa63c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/JdepsMerger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,14 @@ class JdepsMerger {
// so we need to make sure wedon't mart the dependency as unused
// unless all of the jars are unused.
dependencyMap.values.forEach {
val label = readJarOwnerFromManifest(Paths.get(it.path)).label
if (label != null &&
kindMap.getOrDefault(label, Deps.Dependency.Kind.UNUSED) >= it.kind
) {
kindMap.put(label, it.kind)
var label = readJarOwnerFromManifest(Paths.get(it.path)).label
if (label != null) {
if (label.startsWith("@@") || label.startsWith("@/")) {
label = label.substring(1)
}
if (kindMap.getOrDefault(label, Deps.Dependency.Kind.UNUSED) >= it.kind) {
kindMap.put(label, it.kind)
}
}
}

Expand Down

0 comments on commit ecfa63c

Please sign in to comment.