private Map artifactToMap()

in support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateDependencyListMojo.java [100:136]


    private Map<String, String> artifactToMap(Artifact artifact) {
        Map<String, String> dep = new LinkedHashMap<>();
        dep.put("id", artifact.getId());

        if (artifact.getFile() == null) {
            return dep;
        }

        if (includeLocation) {
            dep.put("location", artifact.getFile().getAbsolutePath());
        }

        try {
            String location = artifact.getFile().getAbsolutePath();
            String checksum = null;

            for (String checksumType : CHECKSUM_TYPES) {
                Path checksumFile = Paths.get(location + "." + checksumType);
                if (Files.exists(checksumFile)) {
                    checksum = checksumType + ":" + Files.readString(checksumFile, StandardCharsets.UTF_8);
                    break;
                }
            }

            if (checksum == null) {
                try (InputStream is = Files.newInputStream(artifact.getFile().toPath())) {
                    checksum = "sha1:" + sha1Hex(is);
                }
            }

            dep.put("checksum", checksum);
        } catch (IOException | NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }

        return dep;
    }