Search in sources :

Example 1 with PluginConfiguration

use of com.github.alexcojocaru.mojo.elasticsearch.v2.PluginConfiguration in project elasticsearch-maven-plugin by alexcojocaru.

the class InstallPluginsStep method execute.

@Override
public void execute(InstanceConfiguration config) {
    if (config.getClusterConfiguration().getPlugins().size() > 0) {
        if (VersionUtil.isEqualOrGreater_6_4_0(config.getClusterConfiguration().getVersion())) {
            FilesystemUtil.setScriptPermission(config, "elasticsearch-cli");
        }
        FilesystemUtil.setScriptPermission(config, "elasticsearch-plugin");
    }
    Log log = config.getClusterConfiguration().getLog();
    for (PluginConfiguration plugin : config.getClusterConfiguration().getPlugins()) {
        log.info(String.format("Installing plugin '%s' with options '%s'", plugin.getUri(), plugin.getEsJavaOpts()));
        Map<String, String> environment = new HashMap<>(config.getEnvironmentVariables());
        if (StringUtils.isNotBlank(plugin.getEsJavaOpts())) {
            environment.put("ES_JAVA_OPTS", plugin.getEsJavaOpts());
        }
        CommandLine cmd = ProcessUtil.buildCommandLine("bin/elasticsearch-plugin").addArgument("install").addArgument("--batch").addArgument(plugin.getUri());
        ProcessUtil.executeScript(config, cmd, environment);
    }
}
Also used : CommandLine(org.apache.commons.exec.CommandLine) Log(org.apache.maven.plugin.logging.Log) HashMap(java.util.HashMap) PluginConfiguration(com.github.alexcojocaru.mojo.elasticsearch.v2.PluginConfiguration)

Aggregations

PluginConfiguration (com.github.alexcojocaru.mojo.elasticsearch.v2.PluginConfiguration)1 HashMap (java.util.HashMap)1 CommandLine (org.apache.commons.exec.CommandLine)1 Log (org.apache.maven.plugin.logging.Log)1