@@ -7,7 +7,7 @@ import java.util.jar.Attributes.{ Name => AttributeName }
77
88/** Loads `library.properties` from the jar. */
99object Properties extends PropertiesTrait {
10- protected def propCategory = " library "
10+ protected def propCategory = " compiler "
1111 protected def pickJarBasedOn = classOf [Option [_]]
1212
1313 /** Scala manifest attributes.
@@ -56,36 +56,7 @@ trait PropertiesTrait {
5656 def scalaPropOrElse (name : String , alt : String ): String = scalaProps.getProperty(name, alt)
5757 def scalaPropOrEmpty (name : String ): String = scalaPropOrElse(name, " " )
5858 def scalaPropOrNone (name : String ): Option [String ] = Option (scalaProps.getProperty(name))
59-
60- /** The numeric portion of the runtime Scala version, if this is a final
61- * release. If for instance the versionString says "version 2.9.0.final",
62- * this would return Some("2.9.0").
63- *
64- * @return Some(version) if this is a final release build, None if
65- * it is an RC, Beta, etc. or was built from source, or if the version
66- * cannot be read.
67- */
68- val releaseVersion =
69- for {
70- v <- scalaPropOrNone(" maven.version.number" )
71- if ! (v endsWith " -SNAPSHOT" )
72- } yield v
73-
74- /** The development Scala version, if this is not a final release.
75- * The precise contents are not guaranteed, but it aims to provide a
76- * unique repository identifier (currently the svn revision) in the
77- * fourth dotted segment if the running version was built from source.
78- *
79- * @return Some(version) if this is a non-final version, None if this
80- * is a final release or the version cannot be read.
81- */
82- val developmentVersion =
83- for {
84- v <- scalaPropOrNone(" maven.version.number" )
85- if v endsWith " -SNAPSHOT"
86- ov <- scalaPropOrNone(" version.number" )
87- } yield ov
88-
59+
8960 /** Either the development or release version if known, otherwise
9061 * the empty string.
9162 */
@@ -94,8 +65,16 @@ trait PropertiesTrait {
9465 /** The version number of the jar this was loaded from plus "version " prefix,
9566 * or "version (unknown)" if it cannot be determined.
9667 */
97- val versionString = " version " + " 0.01" // scalaPropOrElse("version.number", "(unknown)")" +
98- val copyrightString = " (c) 2013 LAMP/EPFL" // scalaPropOrElse("copyright.string", "(c) 2002-2011 LAMP/EPFL")
68+ val versionString = {
69+ val v = scalaPropOrElse(" version.number" , " (unknown)" )
70+ " version " + scalaPropOrElse(" version.number" , " (unknown)" ) + {
71+ if (v.contains(" SNAPSHOT" ) || v.contains(" NIGHTLY" )) {
72+ " -git-" + scalaPropOrElse(" git.hash" , " (unknown)" )
73+ } else " "
74+ }
75+ }
76+
77+ val copyrightString = scalaPropOrElse(" copyright.string" , " (c) 2002-2017 LAMP/EPFL" )
9978
10079 /** This is the encoding to use reading in source files, overridden with -encoding
10180 * Note that it uses "prop" i.e. looks in the scala jar, not the system properties.
@@ -140,26 +119,21 @@ trait PropertiesTrait {
140119 def jdkHome = envOrElse(" JDK_HOME" , envOrElse(" JAVA_HOME" , javaHome))
141120
142121 def versionMsg = " Scala %s %s -- %s" .format(propCategory, versionString, copyrightString)
143- def scalaCmd = if (isWin) " scala .bat" else " scala "
144- def scalacCmd = if (isWin) " scalac .bat" else " scalac "
122+ def scalaCmd = if (isWin) " dotr .bat" else " dotr "
123+ def scalacCmd = if (isWin) " dotc .bat" else " dotc "
145124
146125 /** Can the java version be determined to be at least as high as the argument?
147126 * Hard to properly future proof this but at the rate 1.7 is going we can leave
148127 * the issue for our cyborg grandchildren to solve.
149128 */
150129 def isJavaAtLeast (version : String ) = {
151130 val okVersions = version match {
152- case " 1.5" => List (" 1.5" , " 1.6" , " 1.7" )
153- case " 1.6" => List (" 1.6" , " 1.7" )
154- case " 1.7" => List (" 1.7" )
131+ case " 1.5" => List (" 1.5" , " 1.6" , " 1.7" , " 1.8" )
132+ case " 1.6" => List (" 1.6" , " 1.7" , " 1.8" )
133+ case " 1.7" => List (" 1.7" , " 1.8" )
134+ case " 1.8" => List (" 1.8" )
155135 case _ => Nil
156136 }
157137 okVersions exists (javaVersion startsWith _)
158138 }
159-
160- // provide a main method so version info can be obtained by running this
161- def main (args : Array [String ]): Unit = {
162- val writer = new PrintWriter (Console .err, true )
163- writer println versionMsg
164- }
165139}
0 commit comments