diff --git a/core/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java b/core/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java
index b83ca5c5fc6..7a3b254c42d 100644
--- a/core/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java
+++ b/core/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java
@@ -21,6 +21,7 @@ package org.elasticsearch.plugins;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;
+import org.apache.lucene.util.Constants;
import org.apache.lucene.util.IOUtils;
import org.elasticsearch.Build;
import org.elasticsearch.Version;
@@ -68,9 +69,9 @@ import static org.elasticsearch.common.util.set.Sets.newHashSet;
*
* The install command takes a plugin id, which may be any of the following:
*
- * - An official elasticsearch plugin name
- * - Maven coordinates to a plugin zip
- * - A URL to a plugin zip
+ * - An official elasticsearch plugin name
+ * - Maven coordinates to a plugin zip
+ * - A URL to a plugin zip
*
*
* Plugins are packaged as zip files. Each packaged plugin must contain a
@@ -79,9 +80,9 @@ import static org.elasticsearch.common.util.set.Sets.newHashSet;
* The installation process first extracts the plugin files into a temporary
* directory in order to verify the plugin satisfies the following requirements:
*
- * - Jar hell does not exist, either between the plugin's own jars, or with elasticsearch
- * - The plugin is not a module already provided with elasticsearch
- * - If the plugin contains extra security permissions, the policy file is validated
+ * - Jar hell does not exist, either between the plugin's own jars, or with elasticsearch
+ * - The plugin is not a module already provided with elasticsearch
+ * - If the plugin contains extra security permissions, the policy file is validated
*
*
* A plugin may also contain an optional {@code bin} directory which contains scripts. The
@@ -99,34 +100,34 @@ class InstallPluginCommand extends Command {
// TODO: make this a resource file generated by gradle
static final Set MODULES = unmodifiableSet(newHashSet(
- "ingest-grok",
- "lang-expression",
- "lang-groovy",
- "lang-painless",
- "reindex"));
+ "ingest-grok",
+ "lang-expression",
+ "lang-groovy",
+ "lang-painless",
+ "reindex"));
// TODO: make this a resource file generated by gradle
static final Set OFFICIAL_PLUGINS = unmodifiableSet(new LinkedHashSet<>(Arrays.asList(
- "analysis-icu",
- "analysis-kuromoji",
- "analysis-phonetic",
- "analysis-smartcn",
- "analysis-stempel",
- "delete-by-query",
- "discovery-azure",
- "discovery-ec2",
- "discovery-gce",
- "ingest-attachment",
- "ingest-geoip",
- "lang-javascript",
- "lang-python",
- "mapper-attachments",
- "mapper-murmur3",
- "mapper-size",
- "repository-azure",
- "repository-hdfs",
- "repository-s3",
- "store-smb")));
+ "analysis-icu",
+ "analysis-kuromoji",
+ "analysis-phonetic",
+ "analysis-smartcn",
+ "analysis-stempel",
+ "delete-by-query",
+ "discovery-azure",
+ "discovery-ec2",
+ "discovery-gce",
+ "ingest-attachment",
+ "ingest-geoip",
+ "lang-javascript",
+ "lang-python",
+ "mapper-attachments",
+ "mapper-murmur3",
+ "mapper-size",
+ "repository-azure",
+ "repository-hdfs",
+ "repository-s3",
+ "store-smb")));
private final Environment env;
private final OptionSpec batchOption;
@@ -136,7 +137,7 @@ class InstallPluginCommand extends Command {
super("Install a plugin");
this.env = env;
this.batchOption = parser.acceptsAll(Arrays.asList("b", "batch"),
- "Enable batch mode explicitly, automatic confirmation of security permission");
+ "Enable batch mode explicitly, automatic confirmation of security permission");
this.arguments = parser.nonOptions("plugin id");
}
@@ -182,10 +183,10 @@ class InstallPluginCommand extends Command {
final String url;
if (System.getProperty(PROPERTY_SUPPORT_STAGING_URLS, "false").equals("true")) {
url = String.format(Locale.ROOT, "https://download.elastic.co/elasticsearch/staging/%1$s-%2$s/org/elasticsearch/plugin/%3$s/%1$s/%3$s-%1$s.zip",
- version, Build.CURRENT.shortHash(), pluginId);
+ version, Build.CURRENT.shortHash(), pluginId);
} else {
url = String.format(Locale.ROOT, "https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/%1$s/%2$s/%1$s-%2$s.zip",
- pluginId, version);
+ pluginId, version);
}
terminal.println("-> Downloading " + pluginId + " from elastic");
return downloadZipAndChecksum(url, tmpDir);
@@ -195,7 +196,7 @@ class InstallPluginCommand extends Command {
String[] coordinates = pluginId.split(":");
if (coordinates.length == 3 && pluginId.contains("/") == false) {
String mavenUrl = String.format(Locale.ROOT, "https://repo1.maven.org/maven2/%1$s/%2$s/%3$s/%2$s-%3$s.zip",
- coordinates[0].replace(".", "/") /* groupId */, coordinates[1] /* artifactId */, coordinates[2] /* version */);
+ coordinates[0].replace(".", "/") /* groupId */, coordinates[1] /* artifactId */, coordinates[2] /* version */);
terminal.println("-> Downloading " + pluginId + " from maven central");
return downloadZipAndChecksum(mavenUrl, tmpDir);
}
@@ -241,15 +242,20 @@ class InstallPluginCommand extends Command {
private Path unzip(Path zip, Path pluginsDir) throws IOException, UserError {
// unzip plugin to a staging temp dir
- Set perms = new HashSet<>();
- perms.add(PosixFilePermission.OWNER_EXECUTE);
- perms.add(PosixFilePermission.OWNER_READ);
- perms.add(PosixFilePermission.OWNER_WRITE);
- perms.add(PosixFilePermission.GROUP_READ);
- perms.add(PosixFilePermission.GROUP_EXECUTE);
- perms.add(PosixFilePermission.OTHERS_READ);
- perms.add(PosixFilePermission.OTHERS_EXECUTE);
- Path target = Files.createTempDirectory(pluginsDir, ".installing-", PosixFilePermissions.asFileAttribute(perms));
+ final Path target;
+ if (Constants.WINDOWS) {
+ target = Files.createTempDirectory(pluginsDir, ".installing-");
+ } else {
+ Set perms = new HashSet<>();
+ perms.add(PosixFilePermission.OWNER_EXECUTE);
+ perms.add(PosixFilePermission.OWNER_READ);
+ perms.add(PosixFilePermission.OWNER_WRITE);
+ perms.add(PosixFilePermission.GROUP_READ);
+ perms.add(PosixFilePermission.GROUP_EXECUTE);
+ perms.add(PosixFilePermission.OTHERS_READ);
+ perms.add(PosixFilePermission.OTHERS_EXECUTE);
+ target = Files.createTempDirectory(pluginsDir, ".installing-", PosixFilePermissions.asFileAttribute(perms));
+ }
Files.createDirectories(target);
boolean hasEsDir = false;
@@ -279,7 +285,7 @@ class InstallPluginCommand extends Command {
if (entry.isDirectory() == false) {
try (OutputStream out = Files.newOutputStream(targetFile)) {
int len;
- while((len = zipInput.read(buffer)) >= 0) {
+ while ((len = zipInput.read(buffer)) >= 0) {
out.write(buffer, 0, len);
}
}
@@ -408,7 +414,7 @@ class InstallPluginCommand extends Command {
perms.add(PosixFilePermission.OTHERS_EXECUTE);
}
- try (DirectoryStream stream = Files.newDirectoryStream(tmpBinDir)) {
+ try (DirectoryStream stream = Files.newDirectoryStream(tmpBinDir)) {
for (Path srcFile : stream) {
if (Files.isDirectory(srcFile)) {
throw new UserError(ExitCodes.DATA_ERROR, "Directories not allowed in bin dir for plugin " + info.getName() + ", found " + srcFile.getFileName());
@@ -442,7 +448,7 @@ class InstallPluginCommand extends Command {
Files.getFileAttributeView(destConfigDir.getParent(), PosixFileAttributeView.class).readAttributes();
setOwnerGroup(destConfigDir, destConfigDirAttributes);
- try (DirectoryStream stream = Files.newDirectoryStream(tmpConfigDir)) {
+ try (DirectoryStream stream = Files.newDirectoryStream(tmpConfigDir)) {
for (Path srcFile : stream) {
if (Files.isDirectory(srcFile)) {
throw new UserError(ExitCodes.DATA_ERROR, "Directories not allowed in config dir for plugin " + info.getName());