Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

No 'scala-reflect*.jar' warning for Scala 2.10 compiler

  • Loading branch information...
commit bb3463dc80199863338ab2113b5277fafacb04f8 1 parent 7a87421
Pavel Fatin pavelfatin authored
14 jps-plugin/src/org/jetbrains/jps/incremental/scala/data/CompilerData.scala
View
@@ -71,9 +71,19 @@ object CompilerData {
case right => right
}
- compiler.map { compilerJar =>
+ compiler.flatMap { compilerJar =>
val extraJars = files.filterNot(file => file == libraryJar || file == compilerJar)
- CompilerJars(libraryJar, compilerJar, extraJars)
+
+ val reflectJarError = {
+ readProperty(compilerJar, "compiler.properties", "version.number").flatMap {
+ case version if version.startsWith("2.10") => // TODO implement a better version comparison
+ find(extraJars, "scala-reflect", ".jar").left.toOption
+ .map(_ + " in Scala compiler library in " + module.getName)
+ case _ => None
+ }
+ }
+
+ reflectJarError.toLeft(CompilerJars(libraryJar, compilerJar, extraJars))
}
}
}
26 jps-plugin/src/org/jetbrains/jps/incremental/scala/package.scala
View
@@ -1,5 +1,7 @@
package org.jetbrains.jps.incremental
+import _root_.java.io._
+import _root_.java.net.URL
import _root_.java.util.Properties
/**
@@ -31,14 +33,22 @@ package object scala {
}
def readProperty(classLoader: ClassLoader, resource: String, name: String): Option[String] = {
- Option(classLoader.getResourceAsStream(resource)).flatMap { stream =>
- try {
- val properties = new Properties()
- properties.load(stream)
- Option(properties.getProperty(name))
- } finally {
- stream.close()
- }
+ Option(classLoader.getResourceAsStream(resource))
+ .flatMap(it => using(new BufferedInputStream(it))(readProperty(_, name)))
+ }
+
+ def readProperty(file: File, resource: String, name: String): Option[String] = {
+ try {
+ val url = new URL("jar:%s!/%s".format(file.toURI.toString, resource))
+ Option(url.openStream).flatMap(it => using(new BufferedInputStream(it))(readProperty(_, name)))
+ } catch {
+ case _: IOException => None
}
}
+
+ private def readProperty(input: InputStream, name: String): Option[String] = {
+ val properties = new Properties()
+ properties.load(input)
+ Option(properties.getProperty(name))
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.