All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.snyk.snyk_maven_plugin.command.CommandLine Maven / Gradle / Ivy

Go to download

A Maven plguin that allows testing and monitoring of vulnerable dependencies with Snyk

The newest version!
package io.snyk.snyk_maven_plugin.command;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

public interface CommandLine {

    String INTEGRATION_NAME = "MAVEN_PLUGIN";

    Process start() throws IOException;

    static ProcessBuilder asProcessBuilder(
        String cliExecutablePath,
        Command command,
        Optional apiToken,
        List args,
        boolean color
    ) {
        List parts = new ArrayList<>();

        parts.add(cliExecutablePath);
        Collections.addAll(parts, command.commandParameters());
        parts.add("--integration-name=" + INTEGRATION_NAME);

        args.stream()
            .map(String::trim)
            .filter(arg -> !arg.isEmpty())
            .filter(arg -> !arg.startsWith("--integration-name"))
                .forEach(parts::add);

        ProcessBuilder pb = new ProcessBuilder(parts);

        if (color) {
            pb.environment().put("FORCE_COLOR", "true");
        }

        apiToken.ifPresent((t) -> pb.environment().put("SNYK_TOKEN", t));

        return pb;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy