mirror of https://github.com/sbt/sbt.git
Merge branch '1.0.x' into 1.0.x
This commit is contained in:
commit
45765583a6
|
|
@ -27,26 +27,35 @@ object Def extends Init[Scope] with TaskMacroExtra {
|
||||||
Invisible)
|
Invisible)
|
||||||
|
|
||||||
lazy val showFullKey: Show[ScopedKey[_]] = showFullKey(None)
|
lazy val showFullKey: Show[ScopedKey[_]] = showFullKey(None)
|
||||||
|
|
||||||
def showFullKey(keyNameColor: Option[String]): Show[ScopedKey[_]] =
|
def showFullKey(keyNameColor: Option[String]): Show[ScopedKey[_]] =
|
||||||
Show[ScopedKey[_]]((key: ScopedKey[_]) => displayFull(key, keyNameColor))
|
Show[ScopedKey[_]]((key: ScopedKey[_]) => displayFull(key, keyNameColor))
|
||||||
|
|
||||||
def showRelativeKey(current: ProjectRef,
|
def showRelativeKey(
|
||||||
|
current: ProjectRef,
|
||||||
multi: Boolean,
|
multi: Boolean,
|
||||||
keyNameColor: Option[String] = None): Show[ScopedKey[_]] =
|
keyNameColor: Option[String] = None
|
||||||
|
): Show[ScopedKey[_]] =
|
||||||
Show[ScopedKey[_]](
|
Show[ScopedKey[_]](
|
||||||
(key: ScopedKey[_]) =>
|
key =>
|
||||||
Scope.display(key.scope,
|
Scope.display(
|
||||||
|
key.scope,
|
||||||
withColor(key.key.label, keyNameColor),
|
withColor(key.key.label, keyNameColor),
|
||||||
ref => displayRelative(current, multi, ref)))
|
ref => displayRelative(current, multi, ref)
|
||||||
|
))
|
||||||
|
|
||||||
def showBuildRelativeKey(currentBuild: URI,
|
def showBuildRelativeKey(
|
||||||
|
currentBuild: URI,
|
||||||
multi: Boolean,
|
multi: Boolean,
|
||||||
keyNameColor: Option[String] = None): Show[ScopedKey[_]] =
|
keyNameColor: Option[String] = None
|
||||||
|
): Show[ScopedKey[_]] =
|
||||||
Show[ScopedKey[_]](
|
Show[ScopedKey[_]](
|
||||||
(key: ScopedKey[_]) =>
|
key =>
|
||||||
Scope.display(key.scope,
|
Scope.display(
|
||||||
|
key.scope,
|
||||||
withColor(key.key.label, keyNameColor),
|
withColor(key.key.label, keyNameColor),
|
||||||
ref => displayBuildRelative(currentBuild, multi, ref)))
|
ref => displayBuildRelative(currentBuild, multi, ref)
|
||||||
|
))
|
||||||
|
|
||||||
def displayRelative(current: ProjectRef, multi: Boolean, project: Reference): String =
|
def displayRelative(current: ProjectRef, multi: Boolean, project: Reference): String =
|
||||||
project match {
|
project match {
|
||||||
|
|
@ -55,15 +64,19 @@ object Def extends Init[Scope] with TaskMacroExtra {
|
||||||
case ProjectRef(current.build, x) => x + "/"
|
case ProjectRef(current.build, x) => x + "/"
|
||||||
case _ => Reference.display(project) + "/"
|
case _ => Reference.display(project) + "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
def displayBuildRelative(currentBuild: URI, multi: Boolean, project: Reference): String =
|
def displayBuildRelative(currentBuild: URI, multi: Boolean, project: Reference): String =
|
||||||
project match {
|
project match {
|
||||||
case BuildRef(`currentBuild`) => "{.}/"
|
case BuildRef(`currentBuild`) => "{.}/"
|
||||||
case ProjectRef(`currentBuild`, x) => x + "/"
|
case ProjectRef(`currentBuild`, x) => x + "/"
|
||||||
case _ => Reference.display(project) + "/"
|
case _ => Reference.display(project) + "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
def displayFull(scoped: ScopedKey[_]): String = displayFull(scoped, None)
|
def displayFull(scoped: ScopedKey[_]): String = displayFull(scoped, None)
|
||||||
|
|
||||||
def displayFull(scoped: ScopedKey[_], keyNameColor: Option[String]): String =
|
def displayFull(scoped: ScopedKey[_], keyNameColor: Option[String]): String =
|
||||||
Scope.display(scoped.scope, withColor(scoped.key.label, keyNameColor))
|
Scope.display(scoped.scope, withColor(scoped.key.label, keyNameColor))
|
||||||
|
|
||||||
def displayMasked(scoped: ScopedKey[_], mask: ScopeMask): String =
|
def displayMasked(scoped: ScopedKey[_], mask: ScopeMask): String =
|
||||||
Scope.displayMasked(scoped.scope, scoped.key.label, mask)
|
Scope.displayMasked(scoped.scope, scoped.key.label, mask)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,16 +124,22 @@ object Scope {
|
||||||
}
|
}
|
||||||
|
|
||||||
def display(config: ConfigKey): String = config.name + ":"
|
def display(config: ConfigKey): String = config.name + ":"
|
||||||
|
|
||||||
def display(scope: Scope, sep: String): String =
|
def display(scope: Scope, sep: String): String =
|
||||||
displayMasked(scope, sep, showProject, ScopeMask())
|
displayMasked(scope, sep, showProject, ScopeMask())
|
||||||
|
|
||||||
def displayMasked(scope: Scope, sep: String, mask: ScopeMask): String =
|
def displayMasked(scope: Scope, sep: String, mask: ScopeMask): String =
|
||||||
displayMasked(scope, sep, showProject, mask)
|
displayMasked(scope, sep, showProject, mask)
|
||||||
|
|
||||||
def display(scope: Scope, sep: String, showProject: Reference => String): String =
|
def display(scope: Scope, sep: String, showProject: Reference => String): String =
|
||||||
displayMasked(scope, sep, showProject, ScopeMask())
|
displayMasked(scope, sep, showProject, ScopeMask())
|
||||||
def displayMasked(scope: Scope,
|
|
||||||
|
def displayMasked(
|
||||||
|
scope: Scope,
|
||||||
sep: String,
|
sep: String,
|
||||||
showProject: Reference => String,
|
showProject: Reference => String,
|
||||||
mask: ScopeMask): String = {
|
mask: ScopeMask
|
||||||
|
): String = {
|
||||||
import scope.{ project, config, task, extra }
|
import scope.{ project, config, task, extra }
|
||||||
val configPrefix = config.foldStrict(display, "*:", ".:")
|
val configPrefix = config.foldStrict(display, "*:", ".:")
|
||||||
val taskPrefix = task.foldStrict(_.label + "::", "", ".::")
|
val taskPrefix = task.foldStrict(_.label + "::", "", ".::")
|
||||||
|
|
@ -148,9 +154,12 @@ object Scope {
|
||||||
(!mask.task || a.task == b.task) &&
|
(!mask.task || a.task == b.task) &&
|
||||||
(!mask.extra || a.extra == b.extra)
|
(!mask.extra || a.extra == b.extra)
|
||||||
|
|
||||||
def projectPrefix(project: ScopeAxis[Reference],
|
def projectPrefix(
|
||||||
show: Reference => String = showProject): String =
|
project: ScopeAxis[Reference],
|
||||||
|
show: Reference => String = showProject
|
||||||
|
): String =
|
||||||
project.foldStrict(show, "*/", "./")
|
project.foldStrict(show, "*/", "./")
|
||||||
|
|
||||||
def showProject = (ref: Reference) => Reference.display(ref) + "/"
|
def showProject = (ref: Reference) => Reference.display(ref) + "/"
|
||||||
|
|
||||||
def transformTaskName(s: String) = {
|
def transformTaskName(s: String) = {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
/** Specifies the Scope axes that should be used for an operation. `true` indicates an axis should be used. */
|
/** 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,
|
final case class ScopeMask(
|
||||||
|
project: Boolean = true,
|
||||||
config: Boolean = true,
|
config: Boolean = true,
|
||||||
task: Boolean = true,
|
task: Boolean = true,
|
||||||
extra: Boolean = true) {
|
extra: Boolean = true
|
||||||
|
) {
|
||||||
def concatShow(p: String, c: String, t: String, sep: String, x: String): String = {
|
def concatShow(p: String, c: String, t: String, sep: String, x: String): String = {
|
||||||
val sb = new StringBuilder
|
val sb = new StringBuilder
|
||||||
if (project) sb.append(p)
|
if (project) sb.append(p)
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ object Cross {
|
||||||
(currentRef :: currentProject.aggregate.toList.flatMap(findAggregates)).distinct
|
(currentRef :: currentProject.aggregate.toList.flatMap(findAggregates)).distinct
|
||||||
}
|
}
|
||||||
|
|
||||||
private def crossVersions(extracted: Extracted, proj: ProjectRef): Seq[String] = {
|
private def crossVersions(extracted: Extracted, proj: ResolvedReference): Seq[String] = {
|
||||||
import extracted._
|
import extracted._
|
||||||
(crossScalaVersions in proj get structure.data) getOrElse {
|
(crossScalaVersions in proj get structure.data) getOrElse {
|
||||||
// reading scalaVersion is a one-time deal
|
// reading scalaVersion is a one-time deal
|
||||||
|
|
@ -218,12 +218,14 @@ object Cross {
|
||||||
}
|
}
|
||||||
|
|
||||||
private def switchScalaVersion(switch: Switch, state: State): State = {
|
private def switchScalaVersion(switch: Switch, state: State): State = {
|
||||||
val x = Project.extract(state)
|
val extracted = Project.extract(state)
|
||||||
import x._
|
import extracted._
|
||||||
|
|
||||||
|
type ScalaVersion = String
|
||||||
|
|
||||||
val (version, instance) = switch.version match {
|
val (version, instance) = switch.version match {
|
||||||
case ScalaHomeVersion(homePath, resolveVersion, _) =>
|
case ScalaHomeVersion(homePath, resolveVersion, _) =>
|
||||||
val home = IO.resolve(x.currentProject.base, homePath)
|
val home = IO.resolve(extracted.currentProject.base, homePath)
|
||||||
if (home.exists()) {
|
if (home.exists()) {
|
||||||
val instance = ScalaInstance(home)(state.classLoaderCache.apply _)
|
val instance = ScalaInstance(home)(state.classLoaderCache.apply _)
|
||||||
val version = resolveVersion.getOrElse(instance.actualVersion)
|
val version = resolveVersion.getOrElse(instance.actualVersion)
|
||||||
|
|
@ -234,10 +236,10 @@ object Cross {
|
||||||
case NamedScalaVersion(v, _) => (v, None)
|
case NamedScalaVersion(v, _) => (v, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
val binaryVersion = CrossVersion.binaryScalaVersion(version)
|
def logSwitchInfo(
|
||||||
|
included: Seq[(ProjectRef, Seq[ScalaVersion])],
|
||||||
def logSwitchInfo(included: Seq[(ProjectRef, Seq[String])],
|
excluded: Seq[(ProjectRef, Seq[ScalaVersion])]
|
||||||
excluded: Seq[(ProjectRef, Seq[String])]) = {
|
) = {
|
||||||
|
|
||||||
instance.foreach {
|
instance.foreach {
|
||||||
case (home, instance) =>
|
case (home, instance) =>
|
||||||
|
|
@ -255,7 +257,7 @@ object Cross {
|
||||||
def detailedLog(msg: => String) =
|
def detailedLog(msg: => String) =
|
||||||
if (switch.verbose) state.log.info(msg) else state.log.debug(msg)
|
if (switch.verbose) state.log.info(msg) else state.log.debug(msg)
|
||||||
|
|
||||||
def logProject: (ProjectRef, Seq[String]) => Unit = (proj, scalaVersions) => {
|
def logProject: (ProjectRef, Seq[ScalaVersion]) => Unit = (proj, scalaVersions) => {
|
||||||
val current = if (proj == currentRef) "*" else " "
|
val current = if (proj == currentRef) "*" else " "
|
||||||
detailedLog(s" $current ${proj.project} ${scalaVersions.mkString("(", ", ", ")")}")
|
detailedLog(s" $current ${proj.project} ${scalaVersions.mkString("(", ", ", ")")}")
|
||||||
}
|
}
|
||||||
|
|
@ -265,46 +267,54 @@ object Cross {
|
||||||
excluded.foreach(logProject.tupled)
|
excluded.foreach(logProject.tupled)
|
||||||
}
|
}
|
||||||
|
|
||||||
val projects: Seq[Reference] = {
|
val projects: Seq[(ResolvedReference, Seq[ScalaVersion])] = {
|
||||||
val projectScalaVersions =
|
val projectScalaVersions =
|
||||||
structure.allProjectRefs.map(proj => proj -> crossVersions(x, proj))
|
structure.allProjectRefs.map(proj => proj -> crossVersions(extracted, proj))
|
||||||
if (switch.version.force) {
|
if (switch.version.force) {
|
||||||
logSwitchInfo(projectScalaVersions, Nil)
|
logSwitchInfo(projectScalaVersions, Nil)
|
||||||
structure.allProjectRefs ++ structure.units.keys.map(BuildRef.apply)
|
projectScalaVersions ++ structure.units.keys
|
||||||
|
.map(BuildRef.apply)
|
||||||
|
.map(proj => proj -> crossVersions(extracted, proj))
|
||||||
} else {
|
} else {
|
||||||
|
val binaryVersion = CrossVersion.binaryScalaVersion(version)
|
||||||
|
|
||||||
val (included, excluded) = projectScalaVersions.partition {
|
val (included, excluded) = projectScalaVersions.partition {
|
||||||
case (proj, scalaVersions) =>
|
case (_, scalaVersions) =>
|
||||||
scalaVersions.exists(v => CrossVersion.binaryScalaVersion(v) == binaryVersion)
|
scalaVersions.exists(v => CrossVersion.binaryScalaVersion(v) == binaryVersion)
|
||||||
}
|
}
|
||||||
logSwitchInfo(included, excluded)
|
logSwitchInfo(included, excluded)
|
||||||
included.map(_._1)
|
included
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setScalaVersionForProjects(version, instance, projects, state, x)
|
setScalaVersionForProjects(version, instance, projects, state, extracted)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def setScalaVersionForProjects(version: String,
|
private def setScalaVersionForProjects(
|
||||||
|
version: String,
|
||||||
instance: Option[(File, ScalaInstance)],
|
instance: Option[(File, ScalaInstance)],
|
||||||
projects: Seq[Reference],
|
projects: Seq[(ResolvedReference, Seq[String])],
|
||||||
state: State,
|
state: State,
|
||||||
extracted: Extracted): State = {
|
extracted: Extracted
|
||||||
|
): State = {
|
||||||
import extracted._
|
import extracted._
|
||||||
|
|
||||||
val newSettings = projects.flatMap { project =>
|
val newSettings = projects.flatMap {
|
||||||
|
case (project, scalaVersions) =>
|
||||||
val scope = Scope(Select(project), Zero, Zero, Zero)
|
val scope = Scope(Select(project), Zero, Zero, Zero)
|
||||||
|
|
||||||
instance match {
|
instance match {
|
||||||
case Some((home, inst)) =>
|
case Some((home, inst)) =>
|
||||||
Seq(
|
Seq(
|
||||||
scalaVersion in scope := version,
|
scalaVersion in scope := version,
|
||||||
|
crossScalaVersions in scope := scalaVersions,
|
||||||
scalaHome in scope := Some(home),
|
scalaHome in scope := Some(home),
|
||||||
scalaInstance in scope := inst
|
scalaInstance in scope := inst
|
||||||
)
|
)
|
||||||
case None =>
|
case None =>
|
||||||
Seq(
|
Seq(
|
||||||
scalaVersion in scope := version,
|
scalaVersion in scope := version,
|
||||||
|
crossScalaVersions in scope := scalaVersions,
|
||||||
scalaHome in scope := None
|
scalaHome in scope := None
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -312,10 +322,12 @@ object Cross {
|
||||||
|
|
||||||
val filterKeys: Set[AttributeKey[_]] = Set(scalaVersion, scalaHome, scalaInstance).map(_.key)
|
val filterKeys: Set[AttributeKey[_]] = Set(scalaVersion, scalaHome, scalaInstance).map(_.key)
|
||||||
|
|
||||||
|
val projectsContains: Reference => Boolean = projects.map(_._1).toSet.contains
|
||||||
|
|
||||||
// Filter out any old scala version settings that were added, this is just for hygiene.
|
// Filter out any old scala version settings that were added, this is just for hygiene.
|
||||||
val filteredRawAppend = session.rawAppend.filter(_.key match {
|
val filteredRawAppend = session.rawAppend.filter(_.key match {
|
||||||
case ScopedKey(Scope(Select(ref), Zero, Zero, Zero), key)
|
case ScopedKey(Scope(Select(ref), Zero, Zero, Zero), key)
|
||||||
if filterKeys.contains(key) && projects.contains(ref) =>
|
if filterKeys.contains(key) && projectsContains(ref) =>
|
||||||
false
|
false
|
||||||
case _ => true
|
case _ => true
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
[@dwijnand]: https://github.com/dwijnand
|
||||||
|
|
||||||
|
[#3495]: https://github.com/sbt/sbt/issues/3495
|
||||||
|
[#3526]: https://github.com/sbt/sbt/pull/3526
|
||||||
|
|
||||||
|
### Fixes with compatibility implications
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
|
||||||
|
- Fixes `++` so it don't change the value of `crossScalaVersion`. [#3495][]/[#3526][] by [@dwijnand][]
|
||||||
|
|
@ -1,23 +1,31 @@
|
||||||
|
inThisBuild(List(
|
||||||
|
crossScalaVersions := Seq("2.12.1", "2.11.8")
|
||||||
|
))
|
||||||
|
|
||||||
lazy val rootProj = (project in file(".")).
|
lazy val rootProj = (project in file("."))
|
||||||
aggregate(libProj, fooPlugin).
|
.aggregate(libProj, fooPlugin)
|
||||||
settings(
|
.settings(
|
||||||
scalaVersion := "2.12.1"
|
scalaVersion := "2.12.1"
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val libProj = (project in file("lib")).
|
lazy val libProj = (project in file("lib"))
|
||||||
settings(
|
.settings(
|
||||||
name := "foo-lib",
|
name := "foo-lib",
|
||||||
scalaVersion := "2.12.1",
|
scalaVersion := "2.12.1",
|
||||||
crossScalaVersions := Seq("2.12.1", "2.11.8")
|
crossScalaVersions := Seq("2.12.1", "2.11.8")
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val fooPlugin =(project in file("sbt-foo")).
|
lazy val fooPlugin = (project in file("sbt-foo"))
|
||||||
settings(
|
.settings(
|
||||||
name := "sbt-foo",
|
name := "sbt-foo",
|
||||||
sbtPlugin := true,
|
sbtPlugin := true,
|
||||||
scalaVersion := "2.12.1",
|
scalaVersion := "2.12.1",
|
||||||
crossScalaVersions := Seq("2.12.1")
|
crossScalaVersions := Seq("2.12.1")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
lazy val extrasProj = (project in file("extras"))
|
||||||
|
.settings(
|
||||||
|
name := "foo-extras",
|
||||||
|
)
|
||||||
|
|
||||||
addCommandAlias("build", "compile")
|
addCommandAlias("build", "compile")
|
||||||
|
|
|
||||||
|
|
@ -46,3 +46,10 @@ $ exists lib/target/scala-2.12
|
||||||
-$ exists lib/target/scala-2.11
|
-$ exists lib/target/scala-2.11
|
||||||
$ exists sbt-foo/target/scala-2.12
|
$ exists sbt-foo/target/scala-2.12
|
||||||
-$ exists sbt-foo/target/scala-2.11
|
-$ exists sbt-foo/target/scala-2.11
|
||||||
|
|
||||||
|
> clean
|
||||||
|
# Test ++ leaves crossScalaVersions unchanged
|
||||||
|
> ++2.12.1
|
||||||
|
> +extrasProj/compile
|
||||||
|
$ exists extras/target/scala-2.11
|
||||||
|
$ exists extras/target/scala-2.12
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ $ copy-file changes/ThreadRunError.scala src/main/scala/Run.scala
|
||||||
$ copy-file changes/RunExplicitSuccess.scala src/main/scala/Run.scala
|
$ copy-file changes/RunExplicitSuccess.scala src/main/scala/Run.scala
|
||||||
> run
|
> run
|
||||||
|
|
||||||
# explicitly calling System.exit(1) should fail the 'run' task
|
# https://github.com/sbt/sbt/issues/3543
|
||||||
$ copy-file changes/RunExplicitFailure.scala src/main/scala/Run.scala
|
# # explicitly calling System.exit(1) should fail the 'run' task
|
||||||
-> run
|
# $ copy-file changes/RunExplicitFailure.scala src/main/scala/Run.scala
|
||||||
|
# -> run
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
> test
|
# https://github.com/sbt/sbt/issues/3545
|
||||||
-> check
|
# > test
|
||||||
|
# -> check
|
||||||
|
|
||||||
> clean
|
> clean
|
||||||
> set testForkedParallel := true
|
> set testForkedParallel := true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue