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

dev.jbang.cli.DependencyInfoMixin Maven / Gradle / Ivy

There is a newer version: 0.121.0
Show newest version
package dev.jbang.cli;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import picocli.CommandLine;

public class DependencyInfoMixin {
	@CommandLine.Option(names = { "-D" }, description = "set a system property", mapFallbackValue = "true")
	Map properties;
	@CommandLine.Option(names = {
			"--deps" }, converter = CommaSeparatedConverter.class, description = "Add additional dependencies (Use commas to separate them).")
	List dependencies;
	@CommandLine.Option(names = {
			"--repos" }, converter = CommaSeparatedConverter.class, description = "Add additional repositories.")
	List repositories;
	@CommandLine.Option(names = { "--cp", "--class-path" }, description = "Add class path entries.")
	List classpaths;

	public List getDependencies() {
		return dependencies;
	}

	public List getRepositories() {
		return repositories;
	}

	public List getClasspaths() {
		return classpaths;
	}

	public Map getProperties() {
		return properties;
	}

	public List opts() {
		List opts = new ArrayList<>();
		if (properties != null) {
			for (Map.Entry e : properties.entrySet()) {
				opts.add("-D");
				opts.add(e.getKey() + "=" + e.getValue());
			}
		}
		if (dependencies != null) {
			for (String d : dependencies) {
				opts.add("--deps");
				opts.add(d);
			}
		}
		if (repositories != null) {
			for (String r : repositories) {
				opts.add("--repos");
				opts.add(r);
			}
		}
		if (classpaths != null) {
			for (String c : classpaths) {
				opts.add("--cp");
				opts.add(c);
			}
		}
		return opts;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy