diff --git a/server/src/main/java/io/druid/server/StatusResource.java b/server/src/main/java/io/druid/server/StatusResource.java index a2b30268d4d..3625641215c 100644 --- a/server/src/main/java/io/druid/server/StatusResource.java +++ b/server/src/main/java/io/druid/server/StatusResource.java @@ -24,6 +24,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; /** */ @@ -35,11 +38,33 @@ public class StatusResource public Status doGet() { return new Status( - StatusResource.class.getPackage().getImplementationVersion(), + getMavenVersion("io.druid","druid-server"), new Memory(Runtime.getRuntime()) ); } + private String getMavenVersion(String groupId, String artifactId){ + + Properties properties = new Properties(); + try { + InputStream is = StatusResource.class.getClassLoader().getResourceAsStream( + String.format( + "META-INF/maven/%s/%s/pom.properties", + groupId, + artifactId + ) + ); + if (is == null) { + return null; + } + properties.load(is); + } + catch (IOException e) { +// e.printStackTrace(); + } + return properties.getProperty("version"); + } + public static class Status { final String version; final Memory memory;