diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-09 22:50:33 -0500 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-09 23:03:19 -0500 |
commit | a06fdb7e62c5e1c9bd2737ffa7df50e9c31f6b97 (patch) | |
tree | e75ef53a2e7e1d37b02bf7fe98095a7678685ddc /stage2 | |
parent | 616c824f3d49853323a7d776f914281b7544ad41 (diff) | |
download | cbt-a06fdb7e62c5e1c9bd2737ffa7df50e9c31f6b97.tar.gz cbt-a06fdb7e62c5e1c9bd2737ffa7df50e9c31f6b97.tar.bz2 cbt-a06fdb7e62c5e1c9bd2737ffa7df50e9c31f6b97.zip |
more concise runMain in more places
Diffstat (limited to 'stage2')
-rw-r--r-- | stage2/BasicBuild.scala | 5 | ||||
-rw-r--r-- | stage2/Lib.scala | 6 | ||||
-rw-r--r-- | stage2/ToolsTasks.scala | 12 | ||||
-rw-r--r-- | stage2/plugins/Dotty.scala | 14 | ||||
-rw-r--r-- | stage2/plugins/Frege.scala | 5 |
5 files changed, 17 insertions, 25 deletions
diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala index 5f74c99..0d8017f 100644 --- a/stage2/BasicBuild.scala +++ b/stage2/BasicBuild.scala @@ -196,15 +196,14 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge } val scalac = new ScalaCompilerDependency(context.cbtLastModified, context.paths.mavenCache, scalaVersion) - lib.runMain( + scalac.runMain( "scala.tools.nsc.MainGenericRunner", Seq( "-bootclasspath", scalac.classpath.string, "-classpath", classpath.string - ) ++ context.args , - scalac.classLoader + ) ++ context.args ) } diff --git a/stage2/Lib.scala b/stage2/Lib.scala index db1ee6d..46668b7 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -76,10 +76,8 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger){ ) ++ compileArgs ++ sourceFiles.map(_.toString) logger.lib("creating docs for source files "+args.mkString(", ")) redirectOutToErr{ - runMain( - "scala.tools.nsc.ScalaDoc", - args, - new ScalaDependencies(cbtLastModified,mavenCache,scalaVersion).classLoader + new ScalaDependencies(cbtLastModified,mavenCache,scalaVersion).runMain( + "scala.tools.nsc.ScalaDoc", args ) } Some(scaladocTarget) diff --git a/stage2/ToolsTasks.scala b/stage2/ToolsTasks.scala index eb41dd0..15052ae 100644 --- a/stage2/ToolsTasks.scala +++ b/stage2/ToolsTasks.scala @@ -49,22 +49,22 @@ class ToolsTasks( def amm = ammonite def ammonite = { val version = args.lift(1).getOrElse(constants.scalaVersion) - val classLoader = Resolver(mavenCentral).bindOne( + val ammonite = Resolver(mavenCentral).bindOne( MavenDependency( "com.lihaoyi","ammonite-repl_2.11.8",args.lift(1).getOrElse("0.5.8") ) - ).classLoader + ) // FIXME: this does not work quite yet, throws NoSuchFileException: /ammonite/repl/frontend/ReplBridge$.class - lib.runMain( - "ammonite.repl.Main", args.drop(2), classLoader + ammonite.runMain( + "ammonite.repl.Main", args.drop(2) ) } def scala = { val version = args.lift(1).getOrElse(constants.scalaVersion) val scalac = new ScalaCompilerDependency( cbtLastModified, mavenCache, version ) val _args = Seq("-cp", scalac.classpath.string) ++ args.drop(2) - lib.runMain( - "scala.tools.nsc.MainGenericRunner", _args, scalac.classLoader + scalac.runMain( + "scala.tools.nsc.MainGenericRunner", _args ) } def cbtEarlyDependencies = { diff --git a/stage2/plugins/Dotty.scala b/stage2/plugins/Dotty.scala index 8ffcdb6..01ffa27 100644 --- a/stage2/plugins/Dotty.scala +++ b/stage2/plugins/Dotty.scala @@ -78,15 +78,14 @@ class DottyLib( def repl(args: Seq[String], classpath: ClassPath) = { consoleOrFail("Use `cbt direct repl` instead") - lib.runMain( + dottyCompiler.runMain( "dotty.tools.dotc.repl.Main", Seq( "-bootclasspath", dottyCompiler.classpath.string, "-classpath", classpath.string - ) ++ args, - dottyCompiler.classLoader + ) ++ args ) } @@ -144,27 +143,24 @@ class DottyLib( "-d", compileTarget.toString ) val singleArgs = dottyOptions.map( "-S" ++ _ ) - val urls = dottyCompiler.classpath.strings.map("file://"+_).map(new java.net.URL(_)) - val cl = new java.net.URLClassLoader( urls.to ) val code = try{ System.err.println("Compiling with Dotty to " ++ compileTarget.toString) compileTarget.mkdirs redirectOutToErr{ - lib.runMain( + dottyCompiler.runMain( _class, dualArgs ++ singleArgs ++ Seq( "-bootclasspath", dottyCompiler.classpath.string ) ++ ( if(cp.isEmpty) Nil else Seq("-classpath", cp) // let's put cp last. It so long - ) ++ sourceFiles.map(_.toString), - cl + ) ++ sourceFiles.map(_.toString) ) } } catch { case e: Exception => System.err.println(red("Dotty crashed. See https://github.com/lampepfl/dotty/issues. To reproduce run:")) - System.err.println(cl) + System.err.println(dottyCompiler.classLoader) System.out.println(s""" java -cp \\ ${dottyCompiler.classpath.strings.mkString(":\\\n")} \\ diff --git a/stage2/plugins/Frege.scala b/stage2/plugins/Frege.scala index 3598d08..3fcd56b 100644 --- a/stage2/plugins/Frege.scala +++ b/stage2/plugins/Frege.scala @@ -88,10 +88,9 @@ class FregeLib( System.err.println("Compiling with Frege to " ++ compileTarget.toString) compileTarget.mkdirs redirectOutToErr{ - lib.runMain( + fregeDependency.runMain( _class, - dualArgs ++ singleArgs ++ sourceFiles.map(_.toString), - fregeDependency.classLoader + dualArgs ++ singleArgs ++ sourceFiles.map(_.toString) ) } } catch { |