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