mirror of https://github.com/sbt/sbt.git
Merge pull request #2718 from xuwei-k/JavaConverters
use JavaConverters instead of JavaConversions
This commit is contained in:
commit
9335a03837
|
|
@ -6,7 +6,7 @@ package sbt
|
|||
import Predef.{ conforms => _, _ }
|
||||
import java.io.File
|
||||
import java.util.jar.{ Attributes, Manifest }
|
||||
import collection.JavaConversions._
|
||||
import collection.JavaConverters._
|
||||
import sbt.internal.util.Types.:+:
|
||||
import sbt.io.syntax._
|
||||
import sbt.io.IO
|
||||
|
|
@ -34,12 +34,12 @@ object Package {
|
|||
new ManifestAttributes(converted: _*)
|
||||
}
|
||||
|
||||
def mergeAttributes(a1: Attributes, a2: Attributes) = a1 ++= a2
|
||||
def mergeAttributes(a1: Attributes, a2: Attributes) = a1.asScala ++= a2.asScala
|
||||
// merges `mergeManifest` into `manifest` (mutating `manifest` in the process)
|
||||
def mergeManifests(manifest: Manifest, mergeManifest: Manifest): Unit = {
|
||||
mergeAttributes(manifest.getMainAttributes, mergeManifest.getMainAttributes)
|
||||
val entryMap = mapAsScalaMap(manifest.getEntries)
|
||||
for ((key, value) <- mergeManifest.getEntries) {
|
||||
val entryMap = manifest.getEntries.asScala
|
||||
for ((key, value) <- mergeManifest.getEntries.asScala) {
|
||||
entryMap.get(key) match {
|
||||
case Some(attributes) => mergeAttributes(attributes, value)
|
||||
case None => entryMap put (key, value)
|
||||
|
|
@ -55,7 +55,7 @@ object Package {
|
|||
option match {
|
||||
case JarManifest(mergeManifest) => mergeManifests(manifest, mergeManifest)
|
||||
case MainClass(mainClassName) => main.put(Attributes.Name.MAIN_CLASS, mainClassName)
|
||||
case ManifestAttributes(attributes @ _*) => main ++= attributes
|
||||
case ManifestAttributes(attributes @ _*) => main.asScala ++= attributes
|
||||
case _ => log.warn("Ignored unknown package option " + option)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1718,10 +1718,10 @@ object Classpaths {
|
|||
}
|
||||
|
||||
import java.util.LinkedHashSet
|
||||
import collection.JavaConversions.asScalaSet
|
||||
import collection.JavaConverters._
|
||||
def interSort(projectRef: ProjectRef, conf: Configuration, data: Settings[Scope], deps: BuildDependencies): Seq[(ProjectRef, String)] =
|
||||
{
|
||||
val visited = asScalaSet(new LinkedHashSet[(ProjectRef, String)])
|
||||
val visited = (new LinkedHashSet[(ProjectRef, String)]).asScala
|
||||
def visit(p: ProjectRef, c: Configuration): Unit = {
|
||||
val applicableConfigs = allConfigs(c)
|
||||
for (ac <- applicableConfigs) // add all configurations in this project
|
||||
|
|
@ -1758,7 +1758,7 @@ object Classpaths {
|
|||
track: TrackLevel, includeSelf: Boolean, f: (ProjectRef, String, Settings[Scope], TrackLevel) => Task[Classpath]): Task[Classpath] =
|
||||
{
|
||||
val visited = interSort(projectRef, conf, data, deps)
|
||||
val tasks = asScalaSet(new LinkedHashSet[Task[Classpath]])
|
||||
val tasks = (new LinkedHashSet[Task[Classpath]]).asScala
|
||||
for ((dep, c) <- visited)
|
||||
if (includeSelf || (dep != projectRef) || (conf.name != c && self.name != c))
|
||||
tasks += f(dep, c, data, track)
|
||||
|
|
|
|||
|
|
@ -112,8 +112,8 @@ object PluginDiscovery {
|
|||
*/
|
||||
def binaryModuleNames(classpath: Seq[File], loader: ClassLoader, resourceName: String): Seq[String] =
|
||||
{
|
||||
import collection.JavaConversions._
|
||||
loader.getResources(resourceName).toSeq.filter(onClasspath(classpath)) flatMap { u =>
|
||||
import collection.JavaConverters._
|
||||
loader.getResources(resourceName).asScala.toSeq.filter(onClasspath(classpath)) flatMap { u =>
|
||||
IO.readLinesURL(u).map(_.trim).filter(!_.isEmpty)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ private[sbt] final class TaskTimings extends ExecuteProgress[Task] {
|
|||
{
|
||||
val total = System.nanoTime - start
|
||||
println("Total time: " + (total * 1e-6) + " ms")
|
||||
import collection.JavaConversions._
|
||||
import collection.JavaConverters._
|
||||
def sumTimes(in: Seq[(Task[_], Long)]) = in.map(_._2).sum
|
||||
val timingsByName = timings.toSeq.groupBy { case (t, time) => mappedName(t) } mapValues (sumTimes)
|
||||
val timingsByName = timings.asScala.toSeq.groupBy { case (t, time) => mappedName(t) } mapValues (sumTimes)
|
||||
for ((taskName, time) <- timingsByName.toSeq.sortBy(_._2).reverse)
|
||||
println(" " + taskName + ": " + (time * 1e-6) + " ms")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,12 @@ import sbt.internal.util.Types._
|
|||
import Execute._
|
||||
|
||||
import scala.annotation.tailrec
|
||||
import scala.collection.{ mutable, JavaConversions }
|
||||
import scala.collection.mutable
|
||||
import scala.collection.JavaConverters._
|
||||
import mutable.Map
|
||||
|
||||
private[sbt] object Execute {
|
||||
def idMap[A, B]: Map[A, B] = JavaConversions.mapAsScalaMap(new java.util.IdentityHashMap[A, B])
|
||||
def idMap[A, B]: Map[A, B] = (new java.util.IdentityHashMap[A, B]).asScala
|
||||
def pMap[A[_], B[_]]: PMap[A, B] = new DelegatingPMap[A, B](idMap)
|
||||
private[sbt] def completed(p: => Unit): Completed = new Completed {
|
||||
def process(): Unit = p
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ object Incomplete extends Enumeration {
|
|||
def transformBU(i: Incomplete)(f: Incomplete => Incomplete): Incomplete = transform(i, false)(f)
|
||||
def transform(i: Incomplete, topDown: Boolean)(f: Incomplete => Incomplete): Incomplete =
|
||||
{
|
||||
import collection.JavaConversions._
|
||||
val visited: collection.mutable.Map[Incomplete, Incomplete] = new java.util.IdentityHashMap[Incomplete, Incomplete]
|
||||
import collection.JavaConverters._
|
||||
val visited: collection.mutable.Map[Incomplete, Incomplete] = (new java.util.IdentityHashMap[Incomplete, Incomplete]).asScala
|
||||
def visit(inc: Incomplete): Incomplete =
|
||||
visited.getOrElseUpdate(inc, if (topDown) visitCauses(f(inc)) else f(visitCauses(inc)))
|
||||
def visitCauses(inc: Incomplete): Incomplete =
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ private[sbt] object TestStatus {
|
|||
import java.util.Properties
|
||||
def read(f: File): Map[String, Long] =
|
||||
{
|
||||
import scala.collection.JavaConversions.{ propertiesAsScalaMap }
|
||||
import scala.collection.JavaConverters._
|
||||
val properties = new Properties
|
||||
IO.load(properties, f)
|
||||
properties map { case (k, v) => (k, v.toLong) }
|
||||
properties.asScala map { case (k, v) => (k, v.toLong) }
|
||||
}
|
||||
def write(map: Map[String, Long], label: String, f: File): Unit = {
|
||||
val properties = new Properties
|
||||
|
|
|
|||
Loading…
Reference in New Issue