diff options
author | Steve Jenson <stevej@twitter.com> | 2010-10-13 15:42:34 -0700 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-11-07 02:08:36 -0500 |
commit | 1b71e264839b0467fd5d000016727f7214639b76 (patch) | |
tree | 00dfc115011d725ace592664ff01dd57b61ef2d5 /libraries | |
parent | ab6b17de45fd49aef81e969e2b6228a984a5c97a (diff) | |
download | cbt-1b71e264839b0467fd5d000016727f7214639b76.tar.gz cbt-1b71e264839b0467fd5d000016727f7214639b76.tar.bz2 cbt-1b71e264839b0467fd5d000016727f7214639b76.zip |
clean up whitespace and print some errors.
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/eval/Eval.scala | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/libraries/eval/Eval.scala b/libraries/eval/Eval.scala index 791b32e..8a2db1c 100644 --- a/libraries/eval/Eval.scala +++ b/libraries/eval/Eval.scala @@ -1,6 +1,6 @@ package com.twitter.util -import scala.tools.nsc.{Global, Settings} +import scala.tools.nsc.{Global, Settings} import scala.tools.nsc.reporters.ConsoleReporter import scala.runtime._ import java.io.{File, FileWriter} @@ -51,13 +51,13 @@ import java.util.jar._ * * Note that in this example there is no need for any configuration format like Configgy, YAML, etc. * - * So how does this work? Eval takes a file or string and generates a new scala class that has an apply method that + * So how does this work? Eval takes a file or string and generates a new scala class that has an apply method that * evaluates that string. The newly generated file is then compiled. All generated .scala and .class * files are stored, by default, in System.getProperty("java.io.tmpdir"). * * After compilation, a new class loader is created with the temporary dir as the classPath. * The generated class is loaded and then apply() is called. - * + * * This implementation is inspired by * http://scala-programming-language.1934581.n4.nabble.com/Compiler-API-td1992165.html * @@ -124,10 +124,10 @@ object Eval { // It's not clear how many nested jars we should open. val classPathAndClassPathsNestedInJars = configulousClasspath.flatMap { fileName => val nestedClassPath = if (JarFile.findFirstMatchIn(fileName).isDefined) { - val nestedClassPathAttribute = new JarFile(fileName).getManifest.getMainAttributes.getValue("Class-Path") - if (nestedClassPathAttribute != null) { - nestedClassPathAttribute.split(" ").toList - } else Nil + val nestedClassPathAttribute = new JarFile(fileName).getManifest.getMainAttributes.getValue("Class-Path") + if (nestedClassPathAttribute != null) { + nestedClassPathAttribute.split(" ").toList + } else Nil } else Nil List(fileName) ::: nestedClassPath } @@ -138,16 +138,18 @@ object Eval { val pathString = pathList.mkString(java.io.File.pathSeparator) settings.bootclasspath.value = pathString settings.classpath.value = pathString - settings.deprecation.value = true // enable detailed deprecation warnings - settings.unchecked.value = true // enable detailed unchecked warnings + settings.deprecation.value = true // enable detailed deprecation warnings + settings.unchecked.value = true // enable detailed unchecked warnings settings.outdir.value = targetDir.toString - val reporter = new ConsoleReporter(settings) - val compiler = new Global(settings, reporter) + val reporter = new ConsoleReporter(settings) + val compiler = new Global(settings, reporter) (new compiler.Run).compile(List(file.toString)) - if (reporter.hasErrors || reporter.WARNING.count > 0) { - // TODO: throw ... + if (reporter.hasErrors || reporter.WARNING.count > 0) { + // FIXME: use proper logging + System.err.println("reporter has warnings attempting to compile") + reporter.printSummary() } } |