From 4609ba6ad071e0cd1d034c969f0f526d94b52dd7 Mon Sep 17 00:00:00 2001 From: michelou Date: Fri, 11 May 2007 13:16:31 +0000 Subject: [PATCH] added property file to scala-library.jar git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@11012 5e8d7ff9-d8ef-0310-90f0-a4852d11357a --- build.xml | 33 +++++++++++++ src/library/scala/runtime/Properties.scala | 57 ++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 src/library/scala/runtime/Properties.scala diff --git a/build.xml b/build.xml index c9157e97c..00de75755 100644 --- a/build.xml +++ b/build.xml @@ -65,6 +65,7 @@ PROPERTIES + + + + + +
@@ -988,6 +1020,7 @@ GENERATES A DISTRIBUTION +
diff --git a/src/library/scala/runtime/Properties.scala b/src/library/scala/runtime/Properties.scala new file mode 100644 index 000000000..0549b23d3 --- /dev/null +++ b/src/library/scala/runtime/Properties.scala @@ -0,0 +1,57 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +package scala.runtime + +/** A utility to load the library properties from a Java properties file + * included in the jar. + * + * @author Stephane Micheloud + */ +object Properties { + + /** The name of the properties file */ + private val propFilename = "/library.properties" + + /** The loaded properties */ + private val props = { + val props = new java.util.Properties + val stream = classOf[Application].getResourceAsStream(propFilename) + if (stream != null) + props.load(stream) + props + } + + /** The version number of the jar this was loaded from, or + * "(unknown)" if it cannot be determined. + */ + val versionString: String = { + val defaultString = "(unknown)" + "version " + props.getProperty("version.number") + } + + val copyrightString: String = { + val defaultString = "(c) 2002-2007 LAMP/EPFL" + props.getProperty("copyright.string", defaultString) + } + + val encodingString: String = { + val defaultString = "ISO-8859-1" + props.getProperty("file.encoding", defaultString) + } + + private val writer = new java.io.PrintWriter(Console.err, true) + + val versionMsg = "Scala library " + versionString + " -- " + copyrightString + + def main(args: Array[String]) { + writer.println(versionMsg) + } +}