Skip to content

Commit 5964e7a

Browse files
MartinWittI-Al-IstannenSirYwell
authored
fix: 🐛 Include leading zeros in checksums (#399)
Co-authored-by: i-al-istannen <[email protected]> Co-authored-by: SirYwell <[email protected]>
1 parent 8b8d20d commit 5964e7a

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

github_action/lockfile.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"artifactID": "maven-lockfile-github-action",
33
"groupID": "io.github.chains-project",
4-
"version": "4.1.1-SNAPSHOT",
4+
"version": "4.2.1-SNAPSHOT",
55
"lockFileVersion": 1,
66
"dependencies": [
77
{

lockfile.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"artifactID": "maven-lockfile-parent",
33
"groupID": "io.github.chains-project",
4-
"version": "4.1.1-SNAPSHOT",
4+
"version": "4.2.1-SNAPSHOT",
55
"lockFileVersion": 1,
66
"dependencies": [],
77
"mavenPlugins": [

maven_plugin/lockfile.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"artifactID": "maven-lockfile",
33
"groupID": "io.github.chains-project",
4-
"version": "4.1.1-SNAPSHOT",
4+
"version": "4.2.1-SNAPSHOT",
55
"lockFileVersion": 1,
66
"dependencies": [
77
{

maven_plugin/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,5 +284,4 @@
284284
</build>
285285
</profile>
286286
</profiles>
287-
288287
</project>

maven_plugin/src/main/java/io/github/chains_project/maven_lockfile/ValidateChecksumMojo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public void execute() throws MojoExecutionException {
5555
sb.append("Lock file validation failed. Differences:");
5656
sb.append("\n");
5757
sb.append("Your lockfile from file is for:"
58-
+ lockFileFromFile.getGroupId().getValue() + ":"
59-
+ lockFileFromFile.getName().getValue() + ":"
58+
+ lockFileFromFile.getGroupId().getValue()
59+
+ ":" + lockFileFromFile.getName().getValue() + ":"
6060
+ lockFileFromFile.getVersion().getValue() + "\n");
6161
sb.append("Your generated lockfile is for:"
6262
+ lockFileFromProject.getGroupId().getValue() + ":"

maven_plugin/src/main/java/io/github/chains_project/maven_lockfile/checksum/FileSystemChecksumCalculator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package io.github.chains_project.maven_lockfile.checksum;
22

3-
import java.math.BigInteger;
3+
import com.google.common.io.BaseEncoding;
44
import java.nio.file.Files;
55
import java.security.MessageDigest;
66
import java.util.List;
7+
import java.util.Locale;
78
import java.util.Optional;
89
import org.apache.log4j.Logger;
910
import org.apache.maven.artifact.Artifact;
@@ -63,7 +64,8 @@ private Optional<String> calculateChecksumInternal(Artifact artifact) {
6364
MessageDigest messageDigest = MessageDigest.getInstance(checksumAlgorithm);
6465
byte[] fileBuffer = Files.readAllBytes(artifact.getFile().toPath());
6566
byte[] artifactHash = messageDigest.digest(fileBuffer);
66-
return Optional.of(new BigInteger(1, artifactHash).toString(16));
67+
BaseEncoding baseEncoding = BaseEncoding.base16();
68+
return Optional.of(baseEncoding.encode(artifactHash).toLowerCase(Locale.ROOT));
6769
} catch (Exception e) {
6870
LOGGER.warn("Could not calculate checksum for artifact " + artifact, e);
6971
return Optional.empty();

0 commit comments

Comments
 (0)