diff --git a/MIGRATION.md b/MIGRATION.md index 55c6f2d7c..bc223a8da 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -15,3 +15,4 @@ Migration notes - `sbt.Process` and `sbt.ProcessExtra` are gone. Use `scala.sys.process` instead. - `incOptions.value.withNameHashing(...)` option is removed. - the scripted plugin is cross-versioned now, so you must use %% when depending on it +- Removed the methods settingsSets from Project (along with add/setSbtFiles) diff --git a/main/src/main/scala/sbt/Project.scala b/main/src/main/scala/sbt/Project.scala index 87a429e2a..3d0564a2c 100755 --- a/main/src/main/scala/sbt/Project.scala +++ b/main/src/main/scala/sbt/Project.scala @@ -10,7 +10,7 @@ import Project._ import Keys.{ stateBuildStructure, commands, configuration, historyPath, projectCommand, sessionSettings, shellPrompt, templateResolverInfos, serverPort, watch } import Scope.{ GlobalScope, ThisScope } import Def.{ Flattened, Initialize, ScopedKey, Setting } -import sbt.internal.{ Load, BuildStructure, LoadedBuild, LoadedBuildUnit, SettingGraph, SettingCompletions, AddSettings, SessionSettings } +import sbt.internal.{ Load, BuildStructure, LoadedBuild, LoadedBuildUnit, SettingGraph, SettingCompletions, SessionSettings } import sbt.internal.util.{ AttributeKey, AttributeMap, Dag, Relation, Settings, ~> } import sbt.internal.util.Types.{ const, idFun } import sbt.internal.util.complete.DefaultParsers @@ -59,9 +59,6 @@ sealed trait ProjectDefinition[PR <: ProjectReference] { def uses: Seq[PR] = aggregate ++ dependencies.map(_.project) def referenced: Seq[PR] = delegates ++ uses - /** Configures the sources of automatically appended settings.*/ - def auto: AddSettings - /** * The defined [[Plugins]] associated with this project. * A [[AutoPlugin]] is a common label that is used by plugins to determine what settings, if any, to add to a project. @@ -104,15 +101,14 @@ sealed trait Project extends ProjectDefinition[ProjectReference] { dependenciesEval: Eval[Seq[ClasspathDep[ProjectReference]]] = dependenciesEval, delegatesEval: Eval[Seq[ProjectReference]] = delegatesEval, settingsEval: Eval[Seq[Setting[_]]] = settingsEval, - configurations: Seq[Configuration] = configurations, - auto: AddSettings = auto + configurations: Seq[Configuration] = configurations ): Project = unresolved(id, base, aggregateEval = aggregateEval, dependenciesEval = dependenciesEval, delegatesEval = delegatesEval, settingsEval = settingsEval, - configurations, auto, plugins, autoPlugins, projectOrigin) + configurations, plugins, autoPlugins, projectOrigin) def resolve(resolveRef: ProjectReference => ProjectRef): ResolvedProject = { @@ -124,7 +120,7 @@ sealed trait Project extends ProjectDefinition[ProjectReference] { dependenciesEval = dependenciesEval map resolveDeps, delegatesEval = delegatesEval map resolveRefs, settingsEval, - configurations, auto, plugins, autoPlugins, projectOrigin) + configurations, plugins, autoPlugins, projectOrigin) } def resolveBuild(resolveRef: ProjectReference => ProjectReference): Project = { @@ -136,7 +132,7 @@ sealed trait Project extends ProjectDefinition[ProjectReference] { dependenciesEval = dependenciesEval map resolveDeps, delegatesEval = delegatesEval map resolveRefs, settingsEval, - configurations, auto, plugins, autoPlugins, projectOrigin) + configurations, plugins, autoPlugins, projectOrigin) } /** @@ -207,21 +203,6 @@ sealed trait Project extends ProjectDefinition[ProjectReference] { sequenceEval(ss.toSeq) map { ss1 => (ss0: Seq[Def.Setting[_]]) ++ Def.settings(ss1: _*) } }) - /** Configures how settings from other sources, such as .sbt files, are appended to the explicitly specified settings for this project. */ - def settingSets(select: AddSettings*): Project = copy(auto = AddSettings.seq(select: _*)) - - /** - * Adds a list of .sbt files whose settings will be appended to the settings of this project. - * They will be appended after the explicit settings and already defined automatic settings sources. - */ - def addSbtFiles(files: File*): Project = copy(auto = AddSettings.append(auto, AddSettings.sbtFiles(files: _*))) - - /** - * Sets the list of .sbt files to parse for settings to be appended to this project's settings. - * Any configured .sbt files are removed from this project's list. - */ - def setSbtFiles(files: File*): Project = copy(auto = AddSettings.append(AddSettings.clearSbtFiles(auto), AddSettings.sbtFiles(files: _*))) - /** * Sets the [[AutoPlugin]]s of this project. * A [[AutoPlugin]] is a common label that is used by plugins to determine what settings, if any, to enable on a project. @@ -234,19 +215,19 @@ sealed trait Project extends ProjectDefinition[ProjectReference] { private[this] def setPlugins(ns: Plugins): Project = { // TODO: for 0.14.0, use copy when it has the additional `plugins` parameter - unresolved(id, base, aggregateEval = aggregateEval, dependenciesEval = dependenciesEval, delegatesEval = delegatesEval, settingsEval, configurations, auto, ns, autoPlugins, projectOrigin) + unresolved(id, base, aggregateEval = aggregateEval, dependenciesEval = dependenciesEval, delegatesEval = delegatesEval, settingsEval, configurations, ns, autoPlugins, projectOrigin) } /** Definitively set the [[AutoPlugin]]s for this project. */ private[sbt] def setAutoPlugins(autos: Seq[AutoPlugin]): Project = { // TODO: for 0.14.0, use copy when it has the additional `autoPlugins` parameter - unresolved(id, base, aggregateEval = aggregateEval, dependenciesEval = dependenciesEval, delegatesEval = delegatesEval, settingsEval, configurations, auto, plugins, autos, projectOrigin) + unresolved(id, base, aggregateEval = aggregateEval, dependenciesEval = dependenciesEval, delegatesEval = delegatesEval, settingsEval, configurations, plugins, autos, projectOrigin) } /** Definitively set the [[ProjectOrigin]] for this project. */ private[sbt] def setProjectOrigin(origin: ProjectOrigin): Project = { // TODO: for 1.0.x, use withProjectOrigin. - unresolved(id, base, aggregateEval = aggregateEval, dependenciesEval = dependenciesEval, delegatesEval = delegatesEval, settingsEval, configurations, auto, plugins, autoPlugins, origin) + unresolved(id, base, aggregateEval = aggregateEval, dependenciesEval = dependenciesEval, delegatesEval = delegatesEval, settingsEval, configurations, plugins, autoPlugins, origin) } } sealed trait ResolvedProject extends ProjectDefinition[ProjectRef] { @@ -280,7 +261,6 @@ object Project extends ProjectExtra { val delegatesEval: Eval[Seq[PR]], val settingsEval: Eval[Seq[Def.Setting[_]]], val configurations: Seq[Configuration], - val auto: AddSettings, val plugins: Plugins, val autoPlugins: Seq[AutoPlugin], val projectOrigin: ProjectOrigin @@ -303,13 +283,12 @@ object Project extends ProjectExtra { } def apply(id: String, base: File): Project = - unresolved(id, base, evalNil, evalNil, evalNil, evalNil, Nil, AddSettings.allDefaults, Plugins.empty, Nil, ProjectOrigin.Organic) + unresolved(id, base, evalNil, evalNil, evalNil, evalNil, Nil, Plugins.empty, Nil, ProjectOrigin.Organic) // TODO: add parameter for plugins and projectOrigin in 1.0 // TODO: Modify default settings to be the core settings, and automatically add the IvyModule + JvmPlugins. // def apply(id: String, base: File, aggregate: => Seq[ProjectReference] = Nil, dependencies: => Seq[ClasspathDep[ProjectReference]] = Nil, - // delegates: => Seq[ProjectReference] = Nil, settings: => Seq[Def.Setting[_]] = Nil, configurations: Seq[Configuration] = Nil, - // auto: AddSettings = AddSettings.allDefaults): Project = + // delegates: => Seq[ProjectReference] = Nil, settings: => Seq[Def.Setting[_]] = Nil, configurations: Seq[Configuration] = Nil): Project = // unresolved(id, base, aggregate, dependencies, delegates, settings, configurations, auto, Plugins.empty, Nil) // Note: JvmModule/IvyModule auto included... def showContextKey(state: State): Show[ScopedKey[_]] = @@ -328,7 +307,7 @@ object Project extends ProjectExtra { private[sbt] def mkGeneratedRoot(id: String, base: File, aggregate: Eval[Seq[ProjectReference]]): Project = { validProjectID(id).foreach(errMsg => sys.error("Invalid project ID: " + errMsg)) - new ProjectDef[ProjectReference](id, base, aggregate, evalNil, evalNil, evalNil, Nil, AddSettings.allDefaults, Plugins.empty, Nil, ProjectOrigin.GenericRoot) with Project with GeneratedRootProject + new ProjectDef[ProjectReference](id, base, aggregate, evalNil, evalNil, evalNil, Nil, Plugins.empty, Nil, ProjectOrigin.GenericRoot) with Project with GeneratedRootProject } /** Returns None if `id` is a valid Project ID or Some containing the parser error message if it is not.*/ @@ -354,16 +333,16 @@ object Project extends ProjectExtra { def normalizeModuleID(id: String): String = normalizeBase(id) private def resolved(id: String, base: File, aggregateEval: Eval[Seq[ProjectRef]], dependenciesEval: Eval[Seq[ClasspathDep[ProjectRef]]], - delegatesEval: Eval[Seq[ProjectRef]], settingsEval: Eval[Seq[Def.Setting[_]]], configurations: Seq[Configuration], auto: AddSettings, + delegatesEval: Eval[Seq[ProjectRef]], settingsEval: Eval[Seq[Def.Setting[_]]], configurations: Seq[Configuration], plugins: Plugins, autoPlugins: Seq[AutoPlugin], origin: ProjectOrigin): ResolvedProject = - new ProjectDef[ProjectRef](id, base, aggregateEval, dependenciesEval, delegatesEval, settingsEval, configurations, auto, plugins, autoPlugins, origin) with ResolvedProject + new ProjectDef[ProjectRef](id, base, aggregateEval, dependenciesEval, delegatesEval, settingsEval, configurations, plugins, autoPlugins, origin) with ResolvedProject private def unresolved(id: String, base: File, aggregateEval: Eval[Seq[ProjectReference]], dependenciesEval: Eval[Seq[ClasspathDep[ProjectReference]]], - delegatesEval: Eval[Seq[ProjectReference]], settingsEval: Eval[Seq[Def.Setting[_]]], configurations: Seq[Configuration], auto: AddSettings, + delegatesEval: Eval[Seq[ProjectReference]], settingsEval: Eval[Seq[Def.Setting[_]]], configurations: Seq[Configuration], plugins: Plugins, autoPlugins: Seq[AutoPlugin], origin: ProjectOrigin): Project = { validProjectID(id).foreach(errMsg => sys.error("Invalid project ID: " + errMsg)) - new ProjectDef[ProjectReference](id, base, aggregateEval, dependenciesEval, delegatesEval, settingsEval, configurations, auto, plugins, autoPlugins, origin) with Project + new ProjectDef[ProjectReference](id, base, aggregateEval, dependenciesEval, delegatesEval, settingsEval, configurations, plugins, autoPlugins, origin) with Project } final class Constructor(p: ProjectReference) { diff --git a/main/src/main/scala/sbt/internal/Load.scala b/main/src/main/scala/sbt/internal/Load.scala index 8a3eae709..efc82f579 100755 --- a/main/src/main/scala/sbt/internal/Load.scala +++ b/main/src/main/scala/sbt/internal/Load.scala @@ -618,7 +618,7 @@ private[sbt] object Load { // Discover any new project definition for the base directory of this project, and load all settings. // Also return any newly discovered project instances. def discoverAndLoad(p: Project): (Project, Seq[Project], Seq[File]) = { - val (root, discovered, files, generated) = discover(p.auto, p.base) match { + val (root, discovered, files, generated) = discover(AddSettings.allDefaults, p.base) match { case DiscoveredProjects(Some(root), rest, files, generated) => // TODO - We assume here the project defined in a build.sbt WINS because the original was // a phony. However, we may want to 'merge' the two, or only do this if the original was a default @@ -738,7 +738,7 @@ private[sbt] object Load { case p: AutoPlugins => autoPluginSettings(p) case q: Sequence => (Seq.empty[Setting[_]] /: q.sequence) { (b, add) => b ++ expandSettings(add) } } - expandSettings(p.auto) + expandSettings(AddSettings.allDefaults) } // Finally, a project we can use in buildStructure. p.copy(settingsEval = Ev.later(allSettings)).setAutoPlugins(projectPlugins).prefixConfigs(autoConfigs: _*) diff --git a/sbt/src/sbt-test/project/auto-settings/b/build.sbt b/sbt/src/sbt-test/project/auto-settings/b/build.sbt deleted file mode 100644 index e864169d1..000000000 --- a/sbt/src/sbt-test/project/auto-settings/b/build.sbt +++ /dev/null @@ -1 +0,0 @@ -version := "ignored" \ No newline at end of file diff --git a/sbt/src/sbt-test/project/auto-settings/build.sbt b/sbt/src/sbt-test/project/auto-settings/build.sbt deleted file mode 100644 index 7d4a01490..000000000 --- a/sbt/src/sbt-test/project/auto-settings/build.sbt +++ /dev/null @@ -1,37 +0,0 @@ -import AddSettings._ - -// version should be from explicit/a.txt -lazy val root = proj("root", "1.4").settingSets( - buildScalaFiles, - userSettings, - sbtFiles(file("explicit/a.txt")) -) - -// version should be from global/user.sbt -lazy val a = proj("a", "1.1"). - settingSets( buildScalaFiles, userSettings ) - -// version should be the default 0.1-SNAPSHOT -lazy val b = proj("b", "0.1-SNAPSHOT"). - settingSets(buildScalaFiles) - -// version should be from the explicit settings call -lazy val c = proj("c", "0.9").settings(version := "0.9"). - settingSets(buildScalaFiles) - -// version should be from d/build.sbt -lazy val d = proj("d", "1.3").settings(version := "0.9"). - settingSets( buildScalaFiles, defaultSbtFiles ) - -// version should be from global/user.sbt -lazy val e = proj("e", "1.1").settings(version := "0.9"). - settingSets( buildScalaFiles, defaultSbtFiles, sbtFiles(file("../explicit/a.txt")), userSettings ) - -def proj(id: String, expectedVersion: String): Project = - Project(id, if(id == "root") file(".") else file(id)). - settings( - TaskKey[Unit]("check") := { - assert(version.value == expectedVersion, - "Expected version '" + expectedVersion + "', got: " + version.value + " in " + id) - } - ) diff --git a/sbt/src/sbt-test/project/auto-settings/d/build.sbt b/sbt/src/sbt-test/project/auto-settings/d/build.sbt deleted file mode 100644 index 7e86dd0fb..000000000 --- a/sbt/src/sbt-test/project/auto-settings/d/build.sbt +++ /dev/null @@ -1 +0,0 @@ -version := "1.3" \ No newline at end of file diff --git a/sbt/src/sbt-test/project/auto-settings/disabled b/sbt/src/sbt-test/project/auto-settings/disabled deleted file mode 100644 index dcccfd271..000000000 --- a/sbt/src/sbt-test/project/auto-settings/disabled +++ /dev/null @@ -1,13 +0,0 @@ -> plugins - -> root/check - -> a/check - -> b/check - -> c/check - -> d/check - -> e/check \ No newline at end of file diff --git a/sbt/src/sbt-test/project/auto-settings/e/build.sbt b/sbt/src/sbt-test/project/auto-settings/e/build.sbt deleted file mode 100644 index e864169d1..000000000 --- a/sbt/src/sbt-test/project/auto-settings/e/build.sbt +++ /dev/null @@ -1 +0,0 @@ -version := "ignored" \ No newline at end of file diff --git a/sbt/src/sbt-test/project/auto-settings/explicit/a.txt b/sbt/src/sbt-test/project/auto-settings/explicit/a.txt deleted file mode 100644 index 873fd02b0..000000000 --- a/sbt/src/sbt-test/project/auto-settings/explicit/a.txt +++ /dev/null @@ -1 +0,0 @@ -version := "1.4" diff --git a/sbt/src/sbt-test/project/auto-settings/global/user.sbt b/sbt/src/sbt-test/project/auto-settings/global/user.sbt deleted file mode 100644 index 99be66402..000000000 --- a/sbt/src/sbt-test/project/auto-settings/global/user.sbt +++ /dev/null @@ -1 +0,0 @@ -version := "1.1" \ No newline at end of file diff --git a/sbt/src/sbt-test/project/auto-settings/root.sbt b/sbt/src/sbt-test/project/auto-settings/root.sbt deleted file mode 100644 index 7ec0d973f..000000000 --- a/sbt/src/sbt-test/project/auto-settings/root.sbt +++ /dev/null @@ -1 +0,0 @@ -version := "1.2" \ No newline at end of file diff --git a/sbt/src/sbt-test/project/sbt-file-projects/a/a.sbt b/sbt/src/sbt-test/project/sbt-file-projects/a/a.sbt index dd33a306a..67966f6d2 100644 --- a/sbt/src/sbt-test/project/sbt-file-projects/a/a.sbt +++ b/sbt/src/sbt-test/project/sbt-file-projects/a/a.sbt @@ -1,4 +1,2 @@ - val aa = taskKey[Unit]("A task in the 'a' project") - aa := println("Hello.") diff --git a/sbt/src/sbt-test/project/sbt-file-projects/b/build.sbt b/sbt/src/sbt-test/project/sbt-file-projects/b/build.sbt index 0c5fae53d..3c7dc5056 100644 --- a/sbt/src/sbt-test/project/sbt-file-projects/b/build.sbt +++ b/sbt/src/sbt-test/project/sbt-file-projects/b/build.sbt @@ -1,4 +1,2 @@ - val h = taskKey[Unit]("A task in project 'b'") - h := println("Hello.") diff --git a/sbt/src/sbt-test/project/sbt-file-projects/build.sbt b/sbt/src/sbt-test/project/sbt-file-projects/build.sbt index 0de1d3480..dbc0dbfe9 100644 --- a/sbt/src/sbt-test/project/sbt-file-projects/build.sbt +++ b/sbt/src/sbt-test/project/sbt-file-projects/build.sbt @@ -1,12 +1,7 @@ import sbt.internal.AddSettings -val a = "a" -val f = file("a") +val a = project +val b = project + val g = taskKey[Unit]("A task in the root project") - -val p = Project(a, f). - settingSets(AddSettings.autoPlugins, AddSettings.sbtFiles( file("a.sbt") )) - -val b = (project in file("b")) - g := println("Hello.") diff --git a/sbt/src/sbt-test/project/sbt-file-projects/changes/Basic.sbt b/sbt/src/sbt-test/project/sbt-file-projects/changes/basic.sbt similarity index 100% rename from sbt/src/sbt-test/project/sbt-file-projects/changes/Basic.sbt rename to sbt/src/sbt-test/project/sbt-file-projects/changes/basic.sbt diff --git a/sbt/src/sbt-test/project/sbt-file-projects/test b/sbt/src/sbt-test/project/sbt-file-projects/test index d7bf3e913..dbf2e5289 100644 --- a/sbt/src/sbt-test/project/sbt-file-projects/test +++ b/sbt/src/sbt-test/project/sbt-file-projects/test @@ -1,4 +1,3 @@ -# nothing in project/ > g -> root/compile > a/compile @@ -7,7 +6,7 @@ > b/h > c/compile -$ copy-file changes/Basic.sbt basic.sbt +$ copy-file changes/basic.sbt basic.sbt > reload > g > root/compile