mirror of https://github.com/sbt/sbt.git
Merge pull request #472 from coursier/topic/low-level-clean-up
Low level clean up
This commit is contained in:
commit
3cd79fc29c
|
|
@ -308,8 +308,8 @@ lazy val cli = project
|
|||
|
||||
def zipEntries(zipStream: ZipInputStream): Iterator[(ZipEntry, Array[Byte])] =
|
||||
new Iterator[(ZipEntry, Array[Byte])] {
|
||||
var nextEntry = Option.empty[ZipEntry]
|
||||
def update() =
|
||||
private var nextEntry = Option.empty[ZipEntry]
|
||||
private def update() =
|
||||
nextEntry = Option(zipStream.getNextEntry)
|
||||
|
||||
update()
|
||||
|
|
@ -623,12 +623,14 @@ lazy val scalaVersionAgnosticCommonSettings = Seq(
|
|||
Resolver.sonatypeRepo("releases")
|
||||
),
|
||||
scalacOptions ++= {
|
||||
scalaBinaryVersion.value match {
|
||||
val targetJvm = scalaBinaryVersion.value match {
|
||||
case "2.10" | "2.11" =>
|
||||
Seq("-target:jvm-1.6")
|
||||
case _ =>
|
||||
Seq()
|
||||
}
|
||||
|
||||
targetJvm ++ Seq("-feature", "-deprecation")
|
||||
},
|
||||
javacOptions ++= {
|
||||
scalaBinaryVersion.value match {
|
||||
|
|
|
|||
|
|
@ -243,14 +243,14 @@ object Cache {
|
|||
Option(handlerClsCache.get(protocol)) match {
|
||||
case None =>
|
||||
val clsName = s"coursier.cache.protocol.${protocol.capitalize}Handler"
|
||||
def clsOpt(loader: ClassLoader) =
|
||||
def clsOpt(loader: ClassLoader): Option[Class[_]] =
|
||||
try Some(loader.loadClass(clsName))
|
||||
catch {
|
||||
case _: ClassNotFoundException =>
|
||||
None
|
||||
}
|
||||
|
||||
val clsOpt0 = clsOpt(Thread.currentThread().getContextClassLoader)
|
||||
val clsOpt0: Option[Class[_]] = clsOpt(Thread.currentThread().getContextClassLoader)
|
||||
.orElse(clsOpt(getClass.getClassLoader))
|
||||
|
||||
def printError(e: Exception): Unit =
|
||||
|
|
@ -758,7 +758,7 @@ object Cache {
|
|||
|
||||
def parseChecksum(content: String): Option[BigInteger] = {
|
||||
val lines = content
|
||||
.linesIterator
|
||||
.lines
|
||||
.toVector
|
||||
|
||||
parseChecksumLine(lines) orElse parseChecksumAlternative(lines)
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ object CoursierPlugin extends AutoPlugin {
|
|||
coursierArtifactsChecksums := Seq(None),
|
||||
coursierCachePolicies := CachePolicy.default,
|
||||
coursierTtl := Cache.defaultTtl,
|
||||
coursierVerbosity := Settings.defaultVerbosityLevel,
|
||||
coursierVerbosity := Settings.defaultVerbosityLevel(sLog.value),
|
||||
mavenProfiles := Set.empty,
|
||||
coursierResolvers <<= Tasks.coursierResolversTask,
|
||||
coursierRecursiveResolvers <<= Tasks.coursierRecursiveResolversTask,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package coursier
|
||||
|
||||
import sbt.Logger
|
||||
|
||||
import scala.util.{Failure, Success, Try}
|
||||
|
||||
object Settings {
|
||||
|
|
@ -10,7 +12,7 @@ object Settings {
|
|||
else
|
||||
1
|
||||
|
||||
def defaultVerbosityLevel: Int = {
|
||||
def defaultVerbosityLevel(logger: Logger): Int = {
|
||||
|
||||
def fromOption(value: Option[String], description: String): Option[Int] =
|
||||
value.filter(_.nonEmpty).flatMap {
|
||||
|
|
@ -18,8 +20,8 @@ object Settings {
|
|||
Try(str.toInt) match {
|
||||
case Success(level) => Some(level)
|
||||
case Failure(ex) =>
|
||||
Console.err.println(
|
||||
s"Warning: unrecognized $description value (should be an integer), ignoring it."
|
||||
logger.warn(
|
||||
s"unrecognized $description value (should be an integer), ignoring it."
|
||||
)
|
||||
None
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,11 @@ import scala.language.implicitConversions
|
|||
|
||||
// things from sbt-structure
|
||||
object Structure {
|
||||
import Def.Initialize._
|
||||
|
||||
def structure(state: State): Load.BuildStructure =
|
||||
def structure(state: State): BuildStructure =
|
||||
sbt.Project.structure(state)
|
||||
|
||||
implicit def `enrich SettingKey`[T](key: SettingKey[T]) = new {
|
||||
implicit class `enrich SettingKey`[T](key: SettingKey[T]) {
|
||||
def find(state: State): Option[T] =
|
||||
key.get(structure(state).data)
|
||||
|
||||
|
|
@ -22,7 +21,7 @@ object Structure {
|
|||
find(state).getOrElse(default)
|
||||
}
|
||||
|
||||
implicit def `enrich TaskKey`[T](key: TaskKey[T]) = new {
|
||||
implicit class `enrich TaskKey`[T](key: TaskKey[T]) {
|
||||
def find(state: State): Option[sbt.Task[T]] =
|
||||
key.get(structure(state).data)
|
||||
|
||||
|
|
@ -33,10 +32,5 @@ object Structure {
|
|||
val tasks = projects.flatMap(p => key.in(p).get(structure(state).data).map(_.map(it => (p, it))))
|
||||
std.TaskExtra.joinTasks(tasks).join.map(_.toMap)
|
||||
}
|
||||
|
||||
def forAllConfigurations(state: State, configurations: Seq[sbt.Configuration]): sbt.Task[Map[sbt.Configuration, T]] = {
|
||||
val tasks = configurations.flatMap(c => key.in(c).get(structure(state).data).map(_.map(it => (c, it))))
|
||||
std.TaskExtra.joinTasks(tasks).join.map(_.toMap)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ object Tasks {
|
|||
} yield {
|
||||
val publish = publishArtifact.in(projectRef).in(pkgTask).in(config).getOrElse(state, false)
|
||||
if (publish)
|
||||
Option(artifact.in(projectRef).in(pkgTask).in(config).getOrElse(state, null))
|
||||
artifact.in(projectRef).in(pkgTask).in(config).find(state)
|
||||
.map(targetConfig -> _)
|
||||
else
|
||||
None
|
||||
|
|
@ -200,9 +200,7 @@ object Tasks {
|
|||
// Second-way of getting artifacts from SBT
|
||||
// No obvious way of getting the corresponding publishArtifact value for the ones
|
||||
// only here, it seems.
|
||||
val extraSbtArtifacts = Option(artifacts.in(projectRef).getOrElse(state, null))
|
||||
.toSeq
|
||||
.flatten
|
||||
val extraSbtArtifacts = artifacts.in(projectRef).getOrElse(state, Nil)
|
||||
.filterNot(stdArtifactsSet)
|
||||
|
||||
// Seems that SBT does that - if an artifact has no configs,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ libraryDependencies += "com.chuusai" %% "shapeless" % "2.3.41" from {
|
|||
if (!f.exists()) {
|
||||
val url0 = "https://repo1.maven.org/maven2/com/chuusai/shapeless_2.11/2.3.0/shapeless_2.11-2.3.0.jar"
|
||||
|
||||
scala.Console.err.println(s"Fetching $url0")
|
||||
sLog.value.warn(s"Fetching $url0")
|
||||
|
||||
val url = new java.net.URL(url0)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue