~ubuntu-branches/debian/sid/scala/sid

« back to all changes in this revision

Viewing changes to src/compiler/scala/tools/nsc/MainGenericRunner.scala

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg, Mehdi Dogguy, Lucas Satabin, Frank S. Thomas, Emmanuel Bourg
  • Date: 2015-06-05 23:52:59 UTC
  • mfrom: (1.2.11)
  • Revision ID: package-import@ubuntu.com-20150605235259-wk00vgk83dh8o19g
Tags: 2.10.5-1
* Team upload.

[ Mehdi Dogguy ]
* New upstream release (Closes: #744278).

[ Lucas Satabin ]
* Update patches
* Update the clean target
* Update paths of elements to install
* Update watch file

[ Frank S. Thomas ]
* Remove myself from Uploaders.

[ Emmanuel Bourg ]
* The package has been adopted by the Java Team (Closes: #754935)
* Patched the build to avoid downloading libraries from the Internet
* Replaced the minified JavaScript files with unobfuscated ones
* No longer build scala-partest.jar until diffutils is packaged or replaced
* debian/watch: Fixed the versions matched (x.y.z instead of x.y.z..z)
* debian/rules:
  - Added the missing get-orig-source target (Closes: #724704)
  - Improved the clean target
* debian/control:
  - Build depend on scala (>= 2.10) and bnd
  - Use canonical URLs for the Vcs-* fields
  - Standards-Version updated to 3.9.6 (no changes)
* Switch to debhelper level 9

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* NSC -- new Scala compiler
2
 
 * Copyright 2006-2011 LAMP/EPFL
 
2
 * Copyright 2006-2013 LAMP/EPFL
3
3
 * @author  Lex Spoon
4
4
 */
5
5
 
6
6
package scala.tools.nsc
7
7
 
8
 
import java.io.IOException
9
8
import java.net.URL
10
9
import scala.tools.util.PathResolver
11
 
 
12
10
import io.{ File }
13
11
import util.{ ClassPath, ScalaClassLoader }
14
12
import Properties.{ versionString, copyrightString }
15
13
import interpreter.{ ILoop }
16
14
import GenericRunnerCommand._
17
15
 
 
16
object JarRunner extends CommonRunner {
 
17
  def runJar(settings: GenericRunnerSettings, jarPath: String, arguments: Seq[String]): Either[Throwable, Boolean] = {
 
18
    val jar       = new io.Jar(jarPath)
 
19
    val mainClass = jar.mainClass getOrElse sys.error("Cannot find main class for jar: " + jarPath)
 
20
    val jarURLs   = ClassPath expandManifestPath jarPath
 
21
    val urls      = if (jarURLs.isEmpty) File(jarPath).toURL +: settings.classpathURLs else jarURLs
 
22
 
 
23
    if (settings.Ylogcp.value) {
 
24
      Console.err.println("Running jar with these URLs as the classpath:")
 
25
      urls foreach println
 
26
    }
 
27
 
 
28
    runAndCatch(urls, mainClass, arguments)
 
29
  }
 
30
}
 
31
 
18
32
/** An object that runs Scala code.  It has three possible
19
33
  * sources for the code to run: pre-compiled code, a script file,
20
34
  * or interactive entry.
25
39
    false
26
40
  }
27
41
  def errorFn(str: String): Boolean = {
28
 
    Console println str
 
42
    Console.err println str
29
43
    false
30
44
  }
31
45
 
44
58
    def isI   = !settings.loadfiles.isDefault
45
59
    def dashi = settings.loadfiles.value
46
60
 
 
61
    // Deadlocks on startup under -i unless we disable async.
 
62
    if (isI)
 
63
      settings.Yreplsync.value = true
 
64
 
47
65
    def combinedCode  = {
48
66
      val files   = if (isI) dashi map (file => File(file).slurp()) else Nil
49
67
      val str     = if (isE) List(dashe) else Nil
57
75
      case AsScript =>
58
76
        ScriptRunner.runScriptAndCatch(settings, thingToRun, command.arguments)
59
77
      case AsJar    =>
60
 
        ObjectRunner.runAndCatch(
61
 
          File(thingToRun).toURL +: settings.classpathURLs,
62
 
          new io.Jar(thingToRun).mainClass getOrElse sys.error("Cannot find main class for jar: " + thingToRun),
63
 
          command.arguments
64
 
        )
 
78
        JarRunner.runJar(settings, thingToRun, command.arguments)
 
79
      case Error =>
 
80
        Right(false)
65
81
      case _  =>
66
82
        // We start the repl when no arguments are given.
67
83
        Right(new ILoop process settings)