Merge pull request #3865 from dwijnand/fix-Extracted.append

Deprecates Extracted#append for appendWithSession
This commit is contained in:
Dale Wijnand 2018-01-17 10:01:25 +00:00 committed by GitHub
commit 5333d0df08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 2 deletions

View File

@ -120,10 +120,29 @@ final case class Extracted(structure: BuildStructure,
structure.data.get(scope, key) getOrElse sys.error(
display.show(ScopedKey(scope, key)) + " is undefined.")
def append(settings: Seq[Setting[_]], state: State): State = {
@deprecated("This discards session settings. Migrate to appendWithSession or appendWithoutSession.", "1.2.0")
def append(settings: Seq[Setting[_]], state: State): State =
appendWithoutSession(settings, state)
/** Appends the given settings to all the build state settings, including session settings. */
def appendWithSession(settings: Seq[Setting[_]], state: State): State =
appendImpl(settings, state, session.mergeSettings)
/**
* Appends the given settings to the original build state settings, discarding any settings
* appended to the session in the process.
*/
def appendWithoutSession(settings: Seq[Setting[_]], state: State): State =
appendImpl(settings, state, session.original)
private[this] def appendImpl(
settings: Seq[Setting[_]],
state: State,
sessionSettings: Seq[Setting[_]],
): State = {
val appendSettings =
Load.transformSettings(Load.projectScope(currentRef), currentRef.build, rootProject, settings)
val newStructure = Load.reapply(session.original ++ appendSettings, structure)
val newStructure = Load.reapply(sessionSettings ++ appendSettings, structure)
Project.setProject(session, newStructure, state)
}
}

View File

@ -0,0 +1,11 @@
[@dwijnand]: https://github.com/dwijnand
[#3865]: https://github.com/sbt/sbt/pull/3865
### Fixes with compatibility implications
### Improvements
- Deprecates `Extracted#append` in favour of `appendWithSession` or `appendWithoutSession`. [#3865][] by [@dwijnand][]
### Bug fixes