diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackBuild.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackBuild.java deleted file mode 100644 index 1cea4c23bcca0..0000000000000 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackBuild.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ -package org.elasticsearch.xpack.core; - -import org.elasticsearch.core.PathUtils; -import org.elasticsearch.core.SuppressForbidden; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.jar.JarInputStream; -import java.util.jar.Manifest; - -/** - * Information about the built version of x-pack that is running. - */ -public class XPackBuild { - - public static final XPackBuild CURRENT; - - static { - final String shortHash; - final String date; - - Path path = getElasticsearchCodebase(); - if (path.toString().endsWith(".jar")) { - try (JarInputStream jar = new JarInputStream(Files.newInputStream(path))) { - Manifest manifest = jar.getManifest(); - shortHash = manifest.getMainAttributes().getValue("Change"); - date = manifest.getMainAttributes().getValue("Build-Date"); - } catch (IOException e) { - throw new RuntimeException(e); - } - } else { - // not running from a jar (unit tests, IDE) - shortHash = "Unknown"; - date = "Unknown"; - } - - CURRENT = new XPackBuild(shortHash, date); - } - - /** - * Returns path to xpack codebase path - */ - @SuppressForbidden(reason = "looks up path of xpack.jar directly") - static Path getElasticsearchCodebase() { - URL url = XPackBuild.class.getProtectionDomain().getCodeSource().getLocation(); - try { - return PathUtils.get(url.toURI()); - } catch (URISyntaxException bogus) { - throw new RuntimeException(bogus); - } - } - - private String shortHash; - private String date; - - XPackBuild(String shortHash, String date) { - this.shortHash = shortHash; - this.date = date; - } - - public String shortHash() { - return shortHash; - } - - public String date() { - return date; - } -} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/TransportXPackInfoAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/TransportXPackInfoAction.java index 84e27b08c1d38..5a0c6a31d1fb8 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/TransportXPackInfoAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/TransportXPackInfoAction.java @@ -6,6 +6,7 @@ */ package org.elasticsearch.xpack.core.action; +import org.elasticsearch.Build; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; @@ -23,7 +24,6 @@ import org.elasticsearch.protocol.xpack.XPackInfoResponse.LicenseInfo; import org.elasticsearch.tasks.Task; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.core.XPackBuild; import java.util.HashSet; import java.util.List; @@ -58,7 +58,7 @@ protected void doExecute(Task task, XPackInfoRequest request, ActionListener