mirror of https://github.com/sbt/sbt.git
Merge pull request #1989 from dwijnand/inThisBuild
Add inThisBuild, similar to inConfig. Fixes #1847
This commit is contained in:
commit
27bd275343
|
|
@ -592,6 +592,8 @@ trait ProjectExtra {
|
|||
|
||||
implicit def richTaskSessionVar[T](init: Initialize[Task[T]]): Project.RichTaskSessionVar[T] = new Project.RichTaskSessionVar(init)
|
||||
|
||||
def inThisBuild(ss: Seq[Setting[_]]): Seq[Setting[_]] =
|
||||
inScope(ThisScope.copy(project = Select(ThisBuild)))(ss)
|
||||
def inConfig(conf: Configuration)(ss: Seq[Setting[_]]): Seq[Setting[_]] =
|
||||
inScope(ThisScope.copy(config = Select(conf)))((configuration :== conf) +: ss)
|
||||
def inTask(t: Scoped)(ss: Seq[Setting[_]]): Seq[Setting[_]] =
|
||||
|
|
@ -599,6 +601,8 @@ trait ProjectExtra {
|
|||
def inScope(scope: Scope)(ss: Seq[Setting[_]]): Seq[Setting[_]] =
|
||||
Project.transform(Scope.replaceThis(scope), ss)
|
||||
|
||||
private[sbt] def inThisBuild[T](i: Initialize[T]): Initialize[T] =
|
||||
inScope(ThisScope.copy(project = Select(ThisBuild)), i)
|
||||
private[sbt] def inConfig[T](conf: Configuration, i: Initialize[T]): Initialize[T] =
|
||||
inScope(ThisScope.copy(config = Select(conf)), i)
|
||||
private[sbt] def inTask[T](t: Scoped, i: Initialize[T]): Initialize[T] =
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
[@dwijnand]: http://github.com/dwijnand
|
||||
[1847]: https://github.com/sbt/sbt/issues/1847
|
||||
[1989]: https://github.com/sbt/sbt/pull/1989
|
||||
|
||||
### Fixes with compatibility implications
|
||||
|
||||
### Improvements
|
||||
|
||||
- Add `inThisBuild`, similar to `inConfig`, to allow specifying multiple settings in `ThisBuild` scope. [#1847][1847]/[#1989][1989] by [@dwijnand][@dwijnand]
|
||||
|
||||
### Bug fixes
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
val a = settingKey[Int]("an int")
|
||||
|
||||
inThisBuild (
|
||||
a := 1
|
||||
)
|
||||
|
||||
val p = project
|
||||
|
||||
TaskKey[Unit]("check") := {
|
||||
assert((a in p).?.value == Option(1), s"a in p should be Some(1) but is ${(a in p).?.value}")
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
> check
|
||||
Loading…
Reference in New Issue