Skip to content

Commit

Permalink
Improve jdeps artifact output determinism logic
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviernotteghem committed May 22, 2024
1 parent e431985 commit e1ca46b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class JdepsMerger {
reportUnusedDeps: String,
): Int {
val rootBuilder = Deps.Dependencies.newBuilder()
val usedResources = mutableSetOf<String>()
val usedResources = sortedSetOf<String>()
rootBuilder.success = false
rootBuilder.ruleLabel = label

Expand Down Expand Up @@ -92,7 +92,7 @@ class JdepsMerger {
}

rootBuilder.addAllDependency(dependencyMap.values)
rootBuilder.addAllUsedResources(usedResources.sorted())
rootBuilder.addAllUsedResources(usedResources)

rootBuilder.success = true
rootBuilder.build().toByteArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,14 @@ class JdepsGenExtension(
rootBuilder.ruleLabel = targetLabel

val unusedDeps = directDeps.subtract(explicitDeps.keys)
unusedDeps.forEach { jarPath ->
unusedDeps.sorted().forEach { jarPath ->
val dependency = Deps.Dependency.newBuilder()
dependency.kind = Deps.Dependency.Kind.UNUSED
dependency.path = jarPath
rootBuilder.addDependency(dependency)
}

explicitDeps.forEach { (jarPath, usedClasses) ->
explicitDeps.toSortedMap().forEach { (jarPath, usedClasses) ->
val dependency = Deps.Dependency.newBuilder()
dependency.kind = Deps.Dependency.Kind.EXPLICIT
dependency.path = jarPath
Expand All @@ -370,7 +370,7 @@ class JdepsGenExtension(
rootBuilder.addDependency(dependency)
}

implicitDeps.keys.subtract(explicitDeps.keys).forEach {
implicitDeps.keys.subtract(explicitDeps.keys).sorted().forEach {
val dependency = Deps.Dependency.newBuilder()
dependency.kind = Deps.Dependency.Kind.IMPLICIT
dependency.path = it
Expand Down

0 comments on commit e1ca46b

Please sign in to comment.