From e7a21be0ca3cf7152b5798317fff346220caae32 Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Wed, 29 Mar 2017 08:36:39 -0400 Subject: make .scala sources 2.12 compatible --- stage1/Stage1Lib.scala | 3 ++- stage1/resolver.scala | 14 +++++++------- stage2/BasicBuild.scala | 4 ++-- stage2/LazyDependency.scala | 6 +++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/stage1/Stage1Lib.scala b/stage1/Stage1Lib.scala index 392b885..1698621 100644 --- a/stage1/Stage1Lib.scala +++ b/stage1/Stage1Lib.scala @@ -314,9 +314,10 @@ ${sourceFiles.sorted.mkString(" \\\n")} .map( dejavafy ) .orElse{ (cacheFile.exists && cacheFile.lastModified > cbtLastModified).option{ - import collection.JavaConversions._ + import collection.JavaConverters._ val v = Files .readAllLines( cacheFile.toPath, StandardCharsets.UTF_8 ) + .asScala .toStream .map( deserialize ) persistentCache.put(key, Array(System.currentTimeMillis:java.lang.Long, javafy(v))) diff --git a/stage1/resolver.scala b/stage1/resolver.scala index 6134a16..48099e5 100644 --- a/stage1/resolver.scala +++ b/stage1/resolver.scala @@ -108,7 +108,7 @@ trait DependencyImplementation extends Dependency{ def flatClassLoader: Boolean = false - def classLoader: ClassLoader = taskCache[DependencyImplementation]( "classLoader" ).memoize{ + override def classLoader: ClassLoader = taskCache[DependencyImplementation]( "classLoader" ).memoize{ if( flatClassLoader ){ new java.net.URLClassLoader(classpath.strings.map(f => new URL("file://" ++ f)).toArray) } else { @@ -170,13 +170,13 @@ case class BinaryDependency( paths: Seq[File], dependencies: Seq[Dependency] )(i def exportedClasspath = ClassPath(paths) override def lastModified = paths.map(_.lastModifiedRecursive).max // FIXME: cache this def targetClasspath = exportedClasspath - lazy val moduleKey = this.getClass.getName + "(" + paths.mkString(", ") + ")" // PERFORMANCE HOTSPOT + override lazy val moduleKey = this.getClass.getName + "(" + paths.mkString(", ") + ")" // PERFORMANCE HOTSPOT } /** Allows to easily assemble a bunch of dependencies */ case class Dependencies( dependencies: Seq[Dependency] )(implicit val logger: Logger, val transientCache: java.util.Map[AnyRef,AnyRef], val classLoaderCache: ClassLoaderCache) extends DependencyImplementation{ override def lastModified = dependencies.map(_.lastModified).maxOption.getOrElse(0) - lazy val moduleKey = this.getClass.getName + "(" + dependencies.map(_.moduleKey).mkString(", ") + ")" // PERFORMANCE HOTSPOT + override lazy val moduleKey = this.getClass.getName + "(" + dependencies.map(_.moduleKey).mkString(", ") + ")" // PERFORMANCE HOTSPOT def targetClasspath = ClassPath() def exportedClasspath = ClassPath() override def show: String = this.getClass.getSimpleName + "( " + dependencies.map(_.show).mkString(", ") + " )" @@ -184,7 +184,7 @@ case class Dependencies( dependencies: Seq[Dependency] )(implicit val logger: Lo case class PostBuildDependency(target: File, _dependencies: Seq[DependencyImplementation])(implicit val logger: Logger, val transientCache: java.util.Map[AnyRef,AnyRef], val classLoaderCache: ClassLoaderCache) extends DependencyImplementation{ override final lazy val lastModified = (target++".last-success").lastModified - lazy val moduleKey = target.string + override lazy val moduleKey = target.string override def show = s"PostBuildDependency($target)" override def targetClasspath = exportedClasspath override def exportedClasspath = ClassPath( Seq(target) ) @@ -246,7 +246,7 @@ case class BoundMavenDependency( )( implicit val logger: Logger, val transientCache: java.util.Map[AnyRef,AnyRef], val classLoaderCache: ClassLoaderCache ) extends ArtifactInfo with DependencyImplementation{ - lazy val moduleKey = this.getClass.getName + "(" + mavenDependency.serialize + ")" // PERFORMANCE HOTSPOT + override lazy val moduleKey = this.getClass.getName + "(" + mavenDependency.serialize + ")" // PERFORMANCE HOTSPOT override def hashCode = mavenDependency.hashCode override def equals(other: Any) = other match{ case o: BoundMavenDependency => o.mavenDependency == mavenDependency && o.repositories == repositories @@ -284,7 +284,7 @@ case class BoundMavenDependency( def exportedJars = Seq( jar ) override def exportedClasspath = ClassPath( exportedJars ) override def targetClasspath = exportedClasspath - import scala.collection.JavaConversions._ + import scala.collection.JavaConverters._ private def resolve(suffix: String, hash: Option[String], useClassifier: Boolean): File = { logger.resolver(lib.blue("Resolving ")+this) @@ -304,7 +304,7 @@ case class BoundMavenDependency( val result = Files.readAllLines( path, StandardCharsets.UTF_8 - ).mkString("\n").split(" ").head.trim + ).asScala.mkString("\n").split(" ").head.trim classLoaderCache.hashMap.put("hash:"+path, result) result } diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala index 2cf97e5..88922d9 100644 --- a/stage2/BasicBuild.scala +++ b/stage2/BasicBuild.scala @@ -17,7 +17,7 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with SbtDep // will create new instances given the context, which means operations in the // overrides will happen multiple times and if they are not idempotent stuff likely breaks def context: Context - lazy val moduleKey: String = "BaseBuild("+target.string+")" + override lazy val moduleKey: String = "BaseBuild("+target.string+")" implicit def transientCache: java.util.Map[AnyRef,AnyRef] = context.transientCache implicit def libraries(implicit context: Context): libraries = new libraries(context, scalaVersion) @@ -153,7 +153,7 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with SbtDep "-unchecked" ) - final def lastModified: Long = compile.getOrElse(0L) + override final def lastModified: Long = compile.getOrElse(0L) def triggerLoopFiles: Set[File] = sources.toSet diff --git a/stage2/LazyDependency.scala b/stage2/LazyDependency.scala index afc6263..2822638 100644 --- a/stage2/LazyDependency.scala +++ b/stage2/LazyDependency.scala @@ -1,11 +1,11 @@ package cbt class LazyDependency( _dependency: => Dependency )( implicit logger: Logger, transientCache: java.util.Map[AnyRef, AnyRef], classLoaderCache: ClassLoaderCache ) extends Dependency { lazy val dependency = _dependency - def classLoader = dependency.classLoader + override def classLoader = dependency.classLoader def dependenciesArray = Array( dependency ) def exportedClasspathArray = Array() - def lastModified = dependency.lastModified - lazy val moduleKey = show + override def lastModified = dependency.lastModified + override lazy val moduleKey = show def show = s"LazyDependency(${dependency.show})" override def toString = show override def equals( other: Any ) = other match { -- cgit v1.2.3