-
-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the new artifacts hashing algorithm
- Loading branch information
Showing
26 changed files
with
607 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
private/tools/java/com/github/bazelbuild/rules_jvm_external/resolver/ArtifactsHash.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.github.bazelbuild.rules_jvm_external.resolver; | ||
|
||
import com.github.bazelbuild.rules_jvm_external.Coordinates; | ||
import java.util.Collection; | ||
import java.util.Set; | ||
import java.util.TreeSet; | ||
import java.util.stream.Collectors; | ||
|
||
public class ArtifactsHash { | ||
|
||
private ArtifactsHash() { | ||
// utility class | ||
} | ||
|
||
public static int calculateArtifactsHash(Collection<DependencyInfo> infos) { | ||
Set<String> lines = new TreeSet<>(); | ||
|
||
for (DependencyInfo info : infos) { | ||
StringBuilder line = new StringBuilder(); | ||
line.append(info.getCoordinates().toString()) | ||
.append(" | ") | ||
.append(info.getSha256().orElseGet(() -> "")) | ||
.append(" | "); | ||
|
||
line.append( | ||
info.getDependencies().stream() | ||
.map(Coordinates::asKey) | ||
.sorted() | ||
.collect(Collectors.joining(","))); | ||
|
||
lines.add(line.toString()); | ||
} | ||
|
||
return String.join("\n", lines).hashCode(); | ||
} | ||
} |
Oops, something went wrong.