mirror of https://github.com/sbt/sbt.git
Cleanup
This commit is contained in:
parent
363966da28
commit
936733b2b1
|
|
@ -27,26 +27,35 @@ object Def extends Init[Scope] with TaskMacroExtra {
|
|||
Invisible)
|
||||
|
||||
lazy val showFullKey: Show[ScopedKey[_]] = showFullKey(None)
|
||||
|
||||
def showFullKey(keyNameColor: Option[String]): Show[ScopedKey[_]] =
|
||||
Show[ScopedKey[_]]((key: ScopedKey[_]) => displayFull(key, keyNameColor))
|
||||
|
||||
def showRelativeKey(current: ProjectRef,
|
||||
multi: Boolean,
|
||||
keyNameColor: Option[String] = None): Show[ScopedKey[_]] =
|
||||
def showRelativeKey(
|
||||
current: ProjectRef,
|
||||
multi: Boolean,
|
||||
keyNameColor: Option[String] = None
|
||||
): Show[ScopedKey[_]] =
|
||||
Show[ScopedKey[_]](
|
||||
(key: ScopedKey[_]) =>
|
||||
Scope.display(key.scope,
|
||||
withColor(key.key.label, keyNameColor),
|
||||
ref => displayRelative(current, multi, ref)))
|
||||
key =>
|
||||
Scope.display(
|
||||
key.scope,
|
||||
withColor(key.key.label, keyNameColor),
|
||||
ref => displayRelative(current, multi, ref)
|
||||
))
|
||||
|
||||
def showBuildRelativeKey(currentBuild: URI,
|
||||
multi: Boolean,
|
||||
keyNameColor: Option[String] = None): Show[ScopedKey[_]] =
|
||||
def showBuildRelativeKey(
|
||||
currentBuild: URI,
|
||||
multi: Boolean,
|
||||
keyNameColor: Option[String] = None
|
||||
): Show[ScopedKey[_]] =
|
||||
Show[ScopedKey[_]](
|
||||
(key: ScopedKey[_]) =>
|
||||
Scope.display(key.scope,
|
||||
withColor(key.key.label, keyNameColor),
|
||||
ref => displayBuildRelative(currentBuild, multi, ref)))
|
||||
key =>
|
||||
Scope.display(
|
||||
key.scope,
|
||||
withColor(key.key.label, keyNameColor),
|
||||
ref => displayBuildRelative(currentBuild, multi, ref)
|
||||
))
|
||||
|
||||
def displayRelative(current: ProjectRef, multi: Boolean, project: Reference): String =
|
||||
project match {
|
||||
|
|
@ -55,15 +64,19 @@ object Def extends Init[Scope] with TaskMacroExtra {
|
|||
case ProjectRef(current.build, x) => x + "/"
|
||||
case _ => Reference.display(project) + "/"
|
||||
}
|
||||
|
||||
def displayBuildRelative(currentBuild: URI, multi: Boolean, project: Reference): String =
|
||||
project match {
|
||||
case BuildRef(`currentBuild`) => "{.}/"
|
||||
case ProjectRef(`currentBuild`, x) => x + "/"
|
||||
case _ => Reference.display(project) + "/"
|
||||
}
|
||||
|
||||
def displayFull(scoped: ScopedKey[_]): String = displayFull(scoped, None)
|
||||
|
||||
def displayFull(scoped: ScopedKey[_], keyNameColor: Option[String]): String =
|
||||
Scope.display(scoped.scope, withColor(scoped.key.label, keyNameColor))
|
||||
|
||||
def displayMasked(scoped: ScopedKey[_], mask: ScopeMask): String =
|
||||
Scope.displayMasked(scoped.scope, scoped.key.label, mask)
|
||||
|
||||
|
|
|
|||
|
|
@ -124,16 +124,22 @@ object Scope {
|
|||
}
|
||||
|
||||
def display(config: ConfigKey): String = config.name + ":"
|
||||
|
||||
def display(scope: Scope, sep: String): String =
|
||||
displayMasked(scope, sep, showProject, ScopeMask())
|
||||
|
||||
def displayMasked(scope: Scope, sep: String, mask: ScopeMask): String =
|
||||
displayMasked(scope, sep, showProject, mask)
|
||||
|
||||
def display(scope: Scope, sep: String, showProject: Reference => String): String =
|
||||
displayMasked(scope, sep, showProject, ScopeMask())
|
||||
def displayMasked(scope: Scope,
|
||||
sep: String,
|
||||
showProject: Reference => String,
|
||||
mask: ScopeMask): String = {
|
||||
|
||||
def displayMasked(
|
||||
scope: Scope,
|
||||
sep: String,
|
||||
showProject: Reference => String,
|
||||
mask: ScopeMask
|
||||
): String = {
|
||||
import scope.{ project, config, task, extra }
|
||||
val configPrefix = config.foldStrict(display, "*:", ".:")
|
||||
val taskPrefix = task.foldStrict(_.label + "::", "", ".::")
|
||||
|
|
@ -148,9 +154,12 @@ object Scope {
|
|||
(!mask.task || a.task == b.task) &&
|
||||
(!mask.extra || a.extra == b.extra)
|
||||
|
||||
def projectPrefix(project: ScopeAxis[Reference],
|
||||
show: Reference => String = showProject): String =
|
||||
def projectPrefix(
|
||||
project: ScopeAxis[Reference],
|
||||
show: Reference => String = showProject
|
||||
): String =
|
||||
project.foldStrict(show, "*/", "./")
|
||||
|
||||
def showProject = (ref: Reference) => Reference.display(ref) + "/"
|
||||
|
||||
def transformTaskName(s: String) = {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
package sbt
|
||||
|
||||
/** Specifies the Scope axes that should be used for an operation. `true` indicates an axis should be used. */
|
||||
final case class ScopeMask(project: Boolean = true,
|
||||
config: Boolean = true,
|
||||
task: Boolean = true,
|
||||
extra: Boolean = true) {
|
||||
final case class ScopeMask(
|
||||
project: Boolean = true,
|
||||
config: Boolean = true,
|
||||
task: Boolean = true,
|
||||
extra: Boolean = true
|
||||
) {
|
||||
def concatShow(p: String, c: String, t: String, sep: String, x: String): String = {
|
||||
val sb = new StringBuilder
|
||||
if (project) sb.append(p)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
package sbt
|
||||
|
||||
import Keys.{ version, _ }
|
||||
import Keys._
|
||||
import sbt.internal.util.complete.{ DefaultParsers, Parser }
|
||||
import sbt.internal.util.AttributeKey
|
||||
import DefaultParsers._
|
||||
|
|
@ -225,12 +225,12 @@ object Cross {
|
|||
}
|
||||
|
||||
private def switchScalaVersion(switch: Switch, state: State): State = {
|
||||
val x = Project.extract(state)
|
||||
import x._
|
||||
val extracted = Project.extract(state)
|
||||
import extracted._
|
||||
|
||||
val (version, instance) = switch.version match {
|
||||
case ScalaHomeVersion(homePath, resolveVersion, _) =>
|
||||
val home = IO.resolve(x.currentProject.base, homePath)
|
||||
val home = IO.resolve(extracted.currentProject.base, homePath)
|
||||
if (home.exists()) {
|
||||
val instance = ScalaInstance(home)(state.classLoaderCache.apply _)
|
||||
val version = resolveVersion.getOrElse(instance.actualVersion)
|
||||
|
|
@ -243,8 +243,10 @@ object Cross {
|
|||
|
||||
val binaryVersion = CrossVersion.binaryScalaVersion(version)
|
||||
|
||||
def logSwitchInfo(included: Seq[(ProjectRef, Seq[String])],
|
||||
excluded: Seq[(ProjectRef, Seq[String])]) = {
|
||||
def logSwitchInfo(
|
||||
included: Seq[(ProjectRef, Seq[String])],
|
||||
excluded: Seq[(ProjectRef, Seq[String])]
|
||||
) = {
|
||||
|
||||
instance.foreach {
|
||||
case (home, instance) =>
|
||||
|
|
@ -274,14 +276,14 @@ object Cross {
|
|||
|
||||
val projects: Seq[Reference] = {
|
||||
val projectScalaVersions =
|
||||
structure.allProjectRefs.map(proj => proj -> crossVersions(x, proj))
|
||||
structure.allProjectRefs.map(proj => proj -> crossVersions(extracted, proj))
|
||||
if (switch.version.force) {
|
||||
logSwitchInfo(projectScalaVersions, Nil)
|
||||
structure.allProjectRefs ++ structure.units.keys.map(BuildRef.apply)
|
||||
} else {
|
||||
|
||||
val (included, excluded) = projectScalaVersions.partition {
|
||||
case (proj, scalaVersions) =>
|
||||
case (_, scalaVersions) =>
|
||||
scalaVersions.exists(v => CrossVersion.binaryScalaVersion(v) == binaryVersion)
|
||||
}
|
||||
logSwitchInfo(included, excluded)
|
||||
|
|
@ -289,14 +291,16 @@ object Cross {
|
|||
}
|
||||
}
|
||||
|
||||
setScalaVersionForProjects(version, instance, projects, state, x)
|
||||
setScalaVersionForProjects(version, instance, projects, state, extracted)
|
||||
}
|
||||
|
||||
private def setScalaVersionForProjects(version: String,
|
||||
instance: Option[(File, ScalaInstance)],
|
||||
projects: Seq[Reference],
|
||||
state: State,
|
||||
extracted: Extracted): State = {
|
||||
private def setScalaVersionForProjects(
|
||||
version: String,
|
||||
instance: Option[(File, ScalaInstance)],
|
||||
projects: Seq[Reference],
|
||||
state: State,
|
||||
extracted: Extracted
|
||||
): State = {
|
||||
import extracted._
|
||||
|
||||
val newSettings = projects.flatMap { project =>
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
|
||||
lazy val rootProj = (project in file(".")).
|
||||
aggregate(libProj, fooPlugin).
|
||||
settings(
|
||||
lazy val rootProj = (project in file("."))
|
||||
.aggregate(libProj, fooPlugin)
|
||||
.settings(
|
||||
scalaVersion := "2.12.1"
|
||||
)
|
||||
|
||||
lazy val libProj = (project in file("lib")).
|
||||
settings(
|
||||
lazy val libProj = (project in file("lib"))
|
||||
.settings(
|
||||
name := "foo-lib",
|
||||
scalaVersion := "2.12.1",
|
||||
crossScalaVersions := Seq("2.12.1", "2.11.8")
|
||||
)
|
||||
|
||||
lazy val fooPlugin =(project in file("sbt-foo")).
|
||||
settings(
|
||||
lazy val fooPlugin = (project in file("sbt-foo"))
|
||||
.settings(
|
||||
name := "sbt-foo",
|
||||
sbtPlugin := true,
|
||||
scalaVersion := "2.12.1",
|
||||
|
|
|
|||
Loading…
Reference in New Issue