summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-04-17 21:28:03 +0000
committerPaul Phillips <paulp@improving.org>2011-04-17 21:28:03 +0000
commite0653db305c7567664fa500acccd2fd5ad7437c0 (patch)
tree34204a852b88114c6f774ca72350e9d5c9ea79ce /src
parent493da996d8f47f7f08642f15c604a755e1953346 (diff)
downloadscala-e0653db305c7567664fa500acccd2fd5ad7437c0.tar.gz
scala-e0653db305c7567664fa500acccd2fd5ad7437c0.tar.bz2
scala-e0653db305c7567664fa500acccd2fd5ad7437c0.zip
Revised that last botched commit. No review.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/util/Properties.scala34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/library/scala/util/Properties.scala b/src/library/scala/util/Properties.scala
index 0674253ea6..f86df0ee96 100644
--- a/src/library/scala/util/Properties.scala
+++ b/src/library/scala/util/Properties.scala
@@ -59,23 +59,35 @@ private[scala] trait PropertiesTrait {
def scalaPropOrEmpty(name: String): String = scalaPropOrElse(name, "")
def scalaPropOrNone(name: String): Option[String] = Option(scalaProps.getProperty(name))
- /** The runtime scala version, if it has only three dotted segments.
+ /** The numeric portion of the runtime scala version, if this is a final
+ * release. If for instance the versionString says "version 2.9.0.final",
+ * this would return Some("2.9.0").
*
- * @return Some(version) if this is not a development build, None if
- * a development build or if the version cannot be read.
+ * @return Some(version) if this is a final release build, None if
+ * it is an RC, Beta, etc. or was built from source, or if the version
+ * cannot be read.
*/
- val releaseVersion = scalaPropOrNone("version.number") filter (_.split('.').size == 3)
+ val releaseVersion = scalaPropOrNone("version.number") flatMap { s =>
+ val segments = s split '.'
+ if (segments.size == 4 && segments.last == "final") Some(segments take 3 mkString ".") else None
+ }
- /** The development scala version. This is derived from the fourth dotted segment
- * in the version string, which should only be present if built from source.
- * At present it corresponds to the svn revision, but this is not guaranteed
- * to remain the case.
+ /** The development scala version, if this is not a final release.
+ * The precise contents are not guaranteed, but it aims to provide a
+ * unique repository identifier (currently the svn revision) in the
+ * fourth dotted segment if the running version was built from source.
*
- * @return Some(version) if this is a development build, None if it has fewer
- * than four segments or cannot be read.
+ * @return Some(version) if this is a non-final version, None if this
+ * is a final release or the version cannot be read.
*/
val developmentVersion = scalaPropOrNone("version.number") flatMap { s =>
- (s split '.' drop 3).headOption map (_ takeWhile (ch => ch != '-'))
+ val segments = s split '.'
+ if (segments.isEmpty || segments.last == "final")
+ None
+ else if (segments.last startsWith "r")
+ Some(s takeWhile (ch => ch != '-')) // Cutting e.g. 2.10.0.r24774-b20110417125606 to 2.10.0.r24774
+ else
+ Some(s)
}
/** The version number of the jar this was loaded from plus "version " prefix,