Search in sources :

Example 1 with DigestUtils

use of org.apache.commons.codec.digest.DigestUtils in project zaproxy by zaproxy.

the class CreateGitHubRelease method appendChecksumsTable.

private void appendChecksumsTable(StringBuilder body) throws IOException {
    String algorithm = checksumAlgorithm.get();
    body.append("| File | Checksum (").append(algorithm).append(") |\n");
    body.append("|---|---|\n");
    String baseDownloadLink = "https://github.com/" + repo.get() + "/releases/download/" + tag.get() + "/";
    DigestUtils digestUtils = new DigestUtils(algorithm);
    List<File> files = assets.stream().map(e -> e.getFile().getAsFile().get()).sorted((a, b) -> a.getName().compareTo(b.getName())).collect(Collectors.toList());
    for (File file : files) {
        String fileName = file.getName();
        body.append("| [").append(fileName).append("](").append(baseDownloadLink).append(fileName).append(") | `").append(digestUtils.digestAsHex(file)).append("` |\n");
    }
}
Also used : GHRepository(org.kohsuke.github.GHRepository) NamedDomainObjectContainer(org.gradle.api.NamedDomainObjectContainer) GHFileNotFoundException(org.kohsuke.github.GHFileNotFoundException) ArrayList(java.util.ArrayList) TaskAction(org.gradle.api.tasks.TaskAction) PathSensitivity(org.gradle.api.tasks.PathSensitivity) DefaultTask(org.gradle.api.DefaultTask) Path(java.nio.file.Path) GitHubUser(org.zaproxy.zap.GitHubUser) Internal(org.gradle.api.tasks.Internal) GitHub(org.kohsuke.github.GitHub) Action(org.gradle.api.Action) Files(java.nio.file.Files) Project(org.gradle.api.Project) IOException(java.io.IOException) Optional(org.gradle.api.tasks.Optional) Collectors(java.util.stream.Collectors) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) List(java.util.List) RegularFileProperty(org.gradle.api.file.RegularFileProperty) ObjectFactory(org.gradle.api.model.ObjectFactory) Property(org.gradle.api.provider.Property) InputFile(org.gradle.api.tasks.InputFile) PathSensitive(org.gradle.api.tasks.PathSensitive) Nested(org.gradle.api.tasks.Nested) Input(org.gradle.api.tasks.Input) DigestUtils(org.apache.commons.codec.digest.DigestUtils) GHRelease(org.kohsuke.github.GHRelease) InvalidUserDataException(org.gradle.api.InvalidUserDataException) Named(org.gradle.api.Named) DigestUtils(org.apache.commons.codec.digest.DigestUtils) File(java.io.File) InputFile(org.gradle.api.tasks.InputFile)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 DigestUtils (org.apache.commons.codec.digest.DigestUtils)1 Action (org.gradle.api.Action)1 DefaultTask (org.gradle.api.DefaultTask)1 InvalidUserDataException (org.gradle.api.InvalidUserDataException)1 Named (org.gradle.api.Named)1 NamedDomainObjectContainer (org.gradle.api.NamedDomainObjectContainer)1 Project (org.gradle.api.Project)1 RegularFileProperty (org.gradle.api.file.RegularFileProperty)1 ObjectFactory (org.gradle.api.model.ObjectFactory)1 Property (org.gradle.api.provider.Property)1 Input (org.gradle.api.tasks.Input)1 InputFile (org.gradle.api.tasks.InputFile)1