diff options
author | michelou <michelou@epfl.ch> | 2007-05-11 13:16:31 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2007-05-11 13:16:31 +0000 |
commit | 95d627ef594d44c18fddc6556916720c5578bac2 (patch) | |
tree | 1af3f0a59d64c1ea437ea9701f4ce53f96544b83 | |
parent | 59ab197fef66d0b640fca11bd8fa005400bc6429 (diff) | |
download | scala-95d627ef594d44c18fddc6556916720c5578bac2.tar.gz scala-95d627ef594d44c18fddc6556916720c5578bac2.tar.bz2 scala-95d627ef594d44c18fddc6556916720c5578bac2.zip |
added property file to scala-library.jar
-rw-r--r-- | build.xml | 33 | ||||
-rw-r--r-- | src/library/scala/runtime/Properties.scala | 57 |
2 files changed, 90 insertions, 0 deletions
@@ -65,6 +65,7 @@ PROPERTIES <property name="scaladoc.exec.name" value="scaladoc"/> <property name="fsc.exec.name" value="fsc"/> <property name="comp.prop.name" value="compiler.properties"/> + <property name="lib.prop.name" value="library.properties"/> <!-- =========================================================================== ANT INITIALISATION @@ -346,6 +347,16 @@ BUILD LOCAL REFERENCE (LOCKER) LAYER <exclude name="scala/actors/**"/> <excludesfile name="${nsc.excludes.file}" if="excludes.avail"/> </starr> + <echo + file="${locker.dir}/lib/library/${lib.prop.name}" + message="version.number=${version.number}${line.separator}" + append="false" + /> + <echo + file="${locker.dir}/lib/library/${lib.prop.name}" + message="copyright.string=${copyright.string}${line.separator}" + append="true" + /> <!-- Build compiler --> <mkdir dir="${locker.dir}/lib/compiler"/> <starr @@ -466,6 +477,16 @@ BUILD QUICK-TEST LAYER <exclude name="scala/actors/**"/> <excludesfile name="${nsc.excludes.file}" if="excludes.avail"/> </locker> + <echo + file="${quick.dir}/lib/library/${lib.prop.name}" + message="version.number=${version.number}${line.separator}" + append="false" + /> + <echo + file="${quick.dir}/lib/library/${lib.prop.name}" + message="copyright.string=${copyright.string}${line.separator}" + append="true" + /> <!-- Build DBC --> <mkdir dir="${quick.dir}/lib/dbc"/> <locker @@ -668,6 +689,16 @@ TEST <exclude name="scala/actors/**"/> <excludesfile name="${nsc.excludes.file}" if="excludes.avail"/> </quick> + <echo + file="${strap.dir}/lib/library/${lib.prop.name}" + message="version.number=${version.number}${line.separator}" + append="false" + /> + <echo + file="${strap.dir}/lib/library/${lib.prop.name}" + message="copyright.string=${copyright.string}${line.separator}" + append="true" + /> <!-- Build DBC --> <mkdir dir="${strap.dir}/lib/dbc"/> <quick @@ -970,6 +1001,7 @@ GENERATES A DISTRIBUTION <manifest> <attribute name="Signature-Version" value="${version.number}"/> <attribute name="Built-By" value="${user.name}"/> + <attribute name="Main-Class" value="scala.tools.nsc.Main"/> <attribute name="Class-Path" value="${lib.jar.name}"/> <section name="scala/tools/nsc"> <attribute name="Extension-Name" value="scala.tools.nsc"/> @@ -988,6 +1020,7 @@ GENERATES A DISTRIBUTION <manifest> <attribute name="Signature-Version" value="${version.number}"/> <attribute name="Built-By" value="${user.name}"/> + <attribute name="Main-Class" value="scala.runtime.Properties"/> <section name="scala"> <attribute name="Extension-Name" value="scala"/> <attribute name="Specification-Title" value="Scala Library"/> diff --git a/src/library/scala/runtime/Properties.scala b/src/library/scala/runtime/Properties.scala new file mode 100644 index 0000000000..3e46646f2b --- /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) + } +} |