Extract Def.settings from Project#settings.

This allows for the same functionality that using SettingsDefinition in
Project#settings allows (specifying either bare Setting[_] or a Seq[Setting[_]])
to be available outside of the settings for a project, for instance when
defining a val.

In short, it allows:

    val modelSettings = Def.settings(
      sharedSettings,
      libraryDependencies += foo
    )
This commit is contained in:
Dale Wijnand 2015-08-12 23:54:38 +01:00
parent 5a7a1db24b
commit 13c6729507
2 changed files with 3 additions and 1 deletions

View File

@ -10,6 +10,8 @@ import KeyRanks.{ DTask, Invisible }
object Def extends Init[Scope] with TaskMacroExtra {
type Classpath = Seq[Attributed[File]]
def settings(ss: SettingsDefinition*): Seq[Setting[_]] = ss.flatMap(_.settings)
val triggeredBy = AttributeKey[Seq[Task[_]]]("triggered-by")
val runBefore = AttributeKey[Seq[Task[_]]]("run-before")
val resolvedScoped = SettingKey[ScopedKey[_]]("resolved-scoped", "The ScopedKey for the referencing setting or task.", KeyRanks.DSetting)

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: Def.SettingsDefinition*): Project = copy(settings = (settings: Seq[Def.Setting[_]]) ++ ss.flatMap(_.settings))
def settings(ss: Def.SettingsDefinition*): Project = copy(settings = (settings: Seq[Def.Setting[_]]) ++ Def.settings(ss: _*))
@deprecated("Use settingSets method.", "0.13.5")
def autoSettings(select: AddSettings*): Project = settingSets(select.toSeq: _*)