summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/io/Jar.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-03-26 19:42:25 +0000
committerPaul Phillips <paulp@improving.org>2011-03-26 19:42:25 +0000
commit3e5cd92cbb455f046f70552f1dd127404b32f4b2 (patch)
tree1eb91e77e931d2d9dec86a8d9e5b28358a0b9467 /src/compiler/scala/tools/nsc/io/Jar.scala
parentf84a12bfbba20d043800fb8b4af9b2bcf79f9d27 (diff)
downloadscala-3e5cd92cbb455f046f70552f1dd127404b32f4b2.tar.gz
scala-3e5cd92cbb455f046f70552f1dd127404b32f4b2.tar.bz2
scala-3e5cd92cbb455f046f70552f1dd127404b32f4b2.zip
Some accumulated work and polish on classpath a...
Some accumulated work and polish on classpath and jars. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/io/Jar.scala')
-rw-r--r--src/compiler/scala/tools/nsc/io/Jar.scala41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/io/Jar.scala b/src/compiler/scala/tools/nsc/io/Jar.scala
index a9f0acaa00..bd7dbde5ec 100644
--- a/src/compiler/scala/tools/nsc/io/Jar.scala
+++ b/src/compiler/scala/tools/nsc/io/Jar.scala
@@ -1,3 +1,8 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2011 LAMP/EPFL
+ * @author Paul Phillips
+ */
+
package scala.tools.nsc
package io
@@ -5,6 +10,27 @@ import java.io.{ InputStream, OutputStream, IOException, FileNotFoundException,
import java.util.jar._
import collection.JavaConverters._
import Attributes.Name
+import util.ClassPath
+
+// Attributes.Name instances:
+//
+// static Attributes.Name CLASS_PATH
+// static Attributes.Name CONTENT_TYPE
+// static Attributes.Name EXTENSION_INSTALLATION
+// static Attributes.Name EXTENSION_LIST
+// static Attributes.Name EXTENSION_NAME
+// static Attributes.Name IMPLEMENTATION_TITLE
+// static Attributes.Name IMPLEMENTATION_URL
+// static Attributes.Name IMPLEMENTATION_VENDOR
+// static Attributes.Name IMPLEMENTATION_VENDOR_ID
+// static Attributes.Name IMPLEMENTATION_VERSION
+// static Attributes.Name MAIN_CLASS
+// static Attributes.Name MANIFEST_VERSION
+// static Attributes.Name SEALED
+// static Attributes.Name SIGNATURE_VERSION
+// static Attributes.Name SPECIFICATION_TITLE
+// static Attributes.Name SPECIFICATION_VENDOR
+// static Attributes.Name SPECIFICATION_VERSION
class Jar(file: File) extends Iterable[JarEntry] {
def this(path: String) = this(File(path))
@@ -74,21 +100,6 @@ object Jar {
def isJarOrZip(f: Path, examineFile: Boolean): Boolean =
f.hasExtension("zip", "jar") || (examineFile && magicNumberIsZip(f))
- def locateByClass(clazz: Class[_]): Option[File] = {
- try Some(File(clazz.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()))
- catch { case _: Exception => None }
- }
- /** Walks upward from wherever the scala library jar is searching for
- * the given jar name. This approach finds the scala library jar in the
- * release layout and in trunk builds going up from pack.
- */
- def locateByName(name: String): Option[File] = {
- def toSrc(d: Directory) = d.dirs.toList map (_ / name)
- def walk(d: Directory) = d.parents flatMap toSrc find (_.isFile) map (_.toFile)
-
- locateByClass(classOf[ScalaObject]) flatMap (x => walk(x.parent))
- }
-
def create(file: File, sourceDir: Directory, mainClass: String): File = {
val writer = new Jar(file).jarWriter()
writer.manifest(Name.MANIFEST_VERSION) = "1.0"