From ae8c065594aa605734b66c11693e5e584feaeddd Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 23 Mar 2010 04:17:59 +0000 Subject: Went ahead and implemented classpaths as descri... Went ahead and implemented classpaths as described in email to scala-internals on the theory that at this point I must know what I'm doing. ** PUBLIC SERVICE ANNOUNCEMENT ** If your code of whatever kind stopped working with this commit (most likely the error is something like "object scala not found") you can get it working again with either of: passing -usejavacp on the command line set system property "scala.usejavacp" to "true" Either of these will alert scala that you want the java application classpath to be utilized by scala as well. Review by community. --- src/compiler/scala/tools/util/PathResolver.scala | 33 +++++++++--------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'src/compiler/scala/tools/util/PathResolver.scala') diff --git a/src/compiler/scala/tools/util/PathResolver.scala b/src/compiler/scala/tools/util/PathResolver.scala index 58ac3bfa56..3f5b7c4d62 100644 --- a/src/compiler/scala/tools/util/PathResolver.scala +++ b/src/compiler/scala/tools/util/PathResolver.scala @@ -48,29 +48,20 @@ object PathResolver { File(url.getFile).parent.path } getOrElse "" - def classPathEnv = envOrElse("CLASSPATH", "") - def sourcePathEnv = envOrElse("SOURCEPATH", "") // not used - def scalaHomeEnv = envOrElse("SCALA_HOME", "") // not used + // No environment variables are used. It's for the best. + // + // def classPathEnv = envOrElse("CLASSPATH", "") + // def sourcePathEnv = envOrElse("SOURCEPATH", "") + // def scalaHomeEnv = envOrElse("SCALA_HOME", "") + def javaBootClassPath = propOrElse("sun.boot.class.path", searchForBootClasspath) def javaExtDirs = propOrEmpty("java.ext.dirs") - def javaUserClassPath = propOrElse("java.class.path", classPathEnv) - def scalaExtDirs = propOrEmpty("scala.ext.dirs") - def scalaHome = propOrEmpty("scala.home") + def scalaExtDirs = propOrEmpty("scala.ext.dirs") - /** I have distilled everyone's classpath hopes and dreams into the - * question of how to resolve this boolean. Right at this moment if I - * do anything but default to true right here, partest chokes. I'm - * steadily reworking all the places partest gets its hands on the - * classpath so eventually I'll be able to remedy that, at which point - * my current plan is to have this default to false unless some - * property or command line option is supplied. This is negotiable, - * but at this point I can say with confidence that less magic and - * less autodetection is more better. - */ - def useJavaClassPath = true - // hypothetically: - // def useJavaClassPath = propIsSet("scala.classpath.guess") + /** The java classpath and whether to use it. */ + def javaUserClassPath = propOrElse("java.class.path", "") + def useJavaClassPath = propOrFalse("scala.usejavacp") override def toString = """ |object Environment { @@ -95,6 +86,7 @@ object PathResolver { def javaBootClassPath = Environment.javaBootClassPath def javaUserClassPath = Environment.javaUserClassPath def javaExtDirs = Environment.javaExtDirs + def useJavaClassPath = Environment.useJavaClassPath def scalaHome = Environment.scalaHome def scalaHomeDir = Directory(scalaHome) @@ -186,13 +178,12 @@ class PathResolver(settings: Settings, context: JavaContext) { case "sourcepath" => settings.sourcepath.value } - private def useJavaClassPath = !settings.javaignorecp.value && Environment.useJavaClassPath - /** Calculated values based on any given command line options, falling back on * those in Defaults. */ object Calculated { def scalaHome = Defaults.scalaHome + def useJavaClassPath = settings.usejavacp.value || Defaults.useJavaClassPath def javaBootClassPath = cmdLineOrElse("javabootclasspath", Defaults.javaBootClassPath) def javaExtDirs = cmdLineOrElse("javaextdirs", Defaults.javaExtDirs) def javaUserClassPath = if (useJavaClassPath) Defaults.javaUserClassPath else "" -- cgit v1.2.3