In Kite, we parse the version from the POM properites file that Maven builds into our jar for us:
private String getVersion() { String location = "/META-INF/maven/org.kitesdk/kite-tools/pom.properties"; String version = "unknown"; InputStream pomPropertiesStream = null; try { Properties pomProperties = new Properties(); pomPropertiesStream = Main.class.getResourceAsStream(location); pomProperties.load(pomPropertiesStream); version = pomProperties.getProperty("version"); } catch (Exception ex) { if (debug) { console.warn("Unable to determine version from the {} file", location); console.warn("Exception:", ex); } else { console.warn("Unable to determine version from the {} file: {}", location, ex.getMessage()); } } finally { Closeables.closeQuietly(pomPropertiesStream); } return version; } On Tue, Nov 11, 2014 at 10:34 AM, Gwen Shapira <gshap...@cloudera.com> wrote: > In Sqoop we do the following: > > Maven runs a shell script, passing the version as a parameter. > The shell-script generates a small java class, which is then built with a > Maven plugin. > Our code references this generated class when we expose "getVersion()". > > Its complex and ugly, so I'm kind of hoping that there's a better way to do > it :) > > Gwen > > On Tue, Nov 11, 2014 at 9:42 AM, Jun Rao <jun...@gmail.com> wrote: > >> Currently, the version number is only stored in our build config file, >> gradle.properties. Not sure how we can automatically extract it and expose >> it in an mbean. How do other projects do this? >> >> Thanks, >> >> Jun >> >> On Tue, Nov 11, 2014 at 7:05 AM, Otis Gospodnetic < >> otis.gospodne...@gmail.com> wrote: >> >> > Hi Jun, >> > >> > Sounds good. But is the version number stored anywhere from where it >> could >> > be gotten? >> > >> > Thanks, >> > Otis >> > -- >> > Monitoring * Alerting * Anomaly Detection * Centralized Log Management >> > Solr & Elasticsearch Support * http://sematext.com/ >> > >> > >> > On Tue, Nov 11, 2014 at 12:45 AM, Jun Rao <jun...@gmail.com> wrote: >> > >> > > Otis, >> > > >> > > We don't have an api for that now. We can probably expose this as a JMX >> > as >> > > part of kafka-1481. >> > > >> > > Thanks, >> > > >> > > Jun >> > > >> > > On Mon, Nov 10, 2014 at 7:17 PM, Otis Gospodnetic < >> > > otis.gospodne...@gmail.com> wrote: >> > > >> > > > Hi, >> > > > >> > > > Is there a way to detect which version of Kafka one is running? >> > > > Is there an API for that, or a constant with this value, or maybe an >> > > MBean >> > > > or some other way to get to this info? >> > > > >> > > > Thanks, >> > > > Otis >> > > > -- >> > > > Monitoring * Alerting * Anomaly Detection * Centralized Log >> Management >> > > > Solr & Elasticsearch Support * http://sematext.com/ >> > > > >> > > >> > >> -- Joey Echeverria