Well, I'm still not happy with it but at least it makes something like sense. Not sure what the right spot is between too little done and too much. But I do know it's ridiculous the only way to get the version was as part of a string which had had "version " prepended.
Less mess to use a Java Properties object:
ReplyDeletescala> val props = new java.util.Properties()
props: java.util.Properties = {}
scala> props.load(getClass.getResourceAsStream("/library.properties"))
scala> props.getProperty("version.number")
res5: java.lang.String = 2.8.1.final
Thanks stainsby! That is indeed less messy. I'll update the post.
ReplyDeleteHi,
ReplyDeleteHow about:
scala> util.Properties.versionString
res2: java.lang.String = version 2.9.0.RC1
Best,
Ismael
Thanks Ismael!
ReplyDeleteHow about:
ReplyDeletescala> scala.util.Properties.releaseVersion
res0: Option[String] = None
scala> scala.util.Properties.developmentVersion
res1: Option[String] = Some(r24776)
It will help to be using at least oh r24776 or so.
Shoot, now I notice I blew that commit. Will revise.
ReplyDeleteWell, I'm still not happy with it but at least it makes something like sense. Not sure what the right spot is between too little done and too much. But I do know it's ridiculous the only way to get the version was as part of a string which had had "version " prepended.
ReplyDeleteFunctions that return Option[T] are often complemented by a function that accepts a (=>T) and returns T by composing with getOrElse.
ReplyDelete