Merge pull request #1902 from dwijnand/define-project-settings-with-SettingsDefinition

Define Project.settings with SettingsDefinition.
This commit is contained in:
eugene yokota 2015-03-09 10:48:18 -04:00
commit b4a5265aaa
4 changed files with 73 additions and 1 deletions

View File

@ -141,7 +141,7 @@ sealed trait Project extends ProjectDefinition[ProjectReference] {
def aggregate(refs: ProjectReference*): Project = copy(aggregate = (aggregate: Seq[ProjectReference]) ++ refs)
/** Appends settings to the current settings sequence for this project. */
def settings(ss: Setting[_]*): Project = copy(settings = (settings: Seq[Setting[_]]) ++ ss)
def settings(ss: SettingsDefinition*): Project = copy(settings = (settings: Seq[Setting[_]]) ++ ss.flatMap(_.settings))
@deprecated("Use settingSets method.", "0.13.5")
def autoSettings(select: AddSettings*): Project = settingSets(select.toSeq: _*)

View File

@ -0,0 +1,32 @@
[@dwijnand]: https://github.com/dwijnand
[1902]: https://github.com/sbt/sbt/pull/1902
### Fixes with compatibility implications
### Improvements
- Facilitate nicer ways of declaring project settings. See below. [#1902][1902] by [@dwijnand][@dwijnand]
### Bug fixes
### Nicer ways of declaring project settings
Now a `Seq[Setting[_]]` can be passed to `Project.settings` without the needs for "varargs expansion", ie. `: _*`
Instead of:
lazy val foo = project settings (sharedSettings: _*)
It is now possible to do:
lazy val foo = project settings sharedSettings
Also, `Seq[Setting[_]]` can be declared at the same level as individual settings in `Project.settings`, for instance:
lazy val foo = project settings (
sharedSettings,
version := "1.0",
someMoreSettings
)
[#1902][1902] by [@dwijnand][@dwijnand]

View File

@ -0,0 +1,39 @@
// Just checking that existing ways of
// setting up projects typechecks
val sharedSettings1 = Seq(
name := "sharedSettings1"
)
val sharedSettings2 = Seq[Setting[_]](
name := "sharedSettings2"
)
lazy val root = project in file(".")
lazy val oldSchool = (project
settings ((sharedSettings1 ++ sharedSettings2): _*)
settings (
name := "pre seq settings"
)
settings (sharedSettings1: _*)
settings (
name := "mid seq settings"
)
settings (sharedSettings2: _*)
settings (
name := "post seq settings"
)
)
lazy val newSchool = (project
settings sharedSettings1
settings sharedSettings2
settings (
name := "pre seq settings",
sharedSettings1,
name := "mid seq settings",
sharedSettings2,
name := "post seq settings"
)
)

View File

@ -0,0 +1 @@
> about