diff --git a/main/src/main/scala/sbt/Build.scala b/main/src/main/scala/sbt/Build.scala index d36ccbb97..6fd43bda0 100644 --- a/main/src/main/scala/sbt/Build.scala +++ b/main/src/main/scala/sbt/Build.scala @@ -4,7 +4,7 @@ package sbt import java.io.File -import Keys.{ name, organization, thisProject } +import Keys.{ name, organization, thisProject, autoGeneratedProject } import Def.{ ScopedKey, Setting } // name is more like BuildDefinition, but that is too long @@ -49,13 +49,13 @@ object Build { // TODO - Can we move this somewhere else? ordering of settings is causing this to get borked. // if the user has overridden the name, use the normal organization that is derived from the name. organization := { - val overridden = thisProject.value.id == name.value + def isDefault(o: String) = thisProject.value.id == o organization.?.value match { - case Some(o) if !overridden => o - case _ => "default" + case Some(o) if !isDefault(o) => o + case _ => "default" } - //(thisProject, organization, name) { (p, o, n) => if(p.id == n) "default" else o } - } + }, + autoGeneratedProject := true ) def defaultAggregatedProject(id: String, base: File, agg: Seq[ProjectRef]): Project = defaultProject(id, base).aggregate(agg: _*) diff --git a/main/src/main/scala/sbt/Keys.scala b/main/src/main/scala/sbt/Keys.scala index 1f46e57c7..fd1f99f88 100644 --- a/main/src/main/scala/sbt/Keys.scala +++ b/main/src/main/scala/sbt/Keys.scala @@ -36,6 +36,7 @@ object Keys { val sLog = SettingKey[Logger]("setting-logger", "Logger usable by settings during project loading.", CSetting) // Project keys + val autoGeneratedProject = SettingKey[Boolean]("autogeneratedProject", "If it exists, represents that the project (and name) were automaticlaly craeted, rather than user specified.", DSetting) val projectCommand = AttributeKey[Boolean]("project-command", "Marks Commands that were registered for the current Project.", Invisible) val sessionSettings = AttributeKey[SessionSettings]("session-settings", "Tracks current build, project, and setting modifications.", DSetting) val stateBuildStructure = AttributeKey[BuildStructure]("build-structure", "Data structure containing all information about the build definition.", BSetting) diff --git a/sbt/src/sbt-test/project/auto-plugins/build.sbt b/sbt/src/sbt-test/project/auto-plugins/build.sbt index 8819060f1..27cdb97cd 100644 --- a/sbt/src/sbt-test/project/auto-plugins/build.sbt +++ b/sbt/src/sbt-test/project/auto-plugins/build.sbt @@ -18,7 +18,10 @@ lazy val projF = project disablePlugins(plugins.IvyPlugin) check := { - // TODO - this will pass when the raw disablePlugin works. + // Ensure organization on root is overridable. + val rorg = (organization).value // Should be None + same(rorg, "override", "organization") + // this will pass when the raw disablePlugin works. val dversion = (projectID in projD).?.value // Should be None same(dversion, None, "projectID in projD") val rversion = projectID.?.value // Should be None @@ -44,6 +47,8 @@ check := { same(qValue, Some(" Q R"), "del in projC in q") val optInValue = (del in projE in q).value same(optInValue, " Q S R", "del in projE in q") + val overrideOrgValue = (organization in projE).value + same(overrideOrgValue, "S", "organization in projE") } keyTest := "foo" diff --git a/sbt/src/sbt-test/project/auto-plugins/project/Q.scala b/sbt/src/sbt-test/project/auto-plugins/project/Q.scala index afdf64b78..b607b170b 100644 --- a/sbt/src/sbt-test/project/auto-plugins/project/Q.scala +++ b/sbt/src/sbt-test/project/auto-plugins/project/Q.scala @@ -1,7 +1,7 @@ package sbttest // you need package http://stackoverflow.com/questions/9822008/ import sbt._ - import sbt.Keys.{name, resolvedScoped} + import sbt.Keys.{name, resolvedScoped, organization } import java.util.concurrent.atomic.{AtomicInteger => AInt} object Imports @@ -19,6 +19,13 @@ object Imports lazy val check = taskKey[Unit]("Verifies settings are as they should be.") } +object OrgPlugin extends AutoPlugin { + override def trigger = allRequirements + override def projectSettings = Seq( + organization := "override" + ) +} + object X extends AutoPlugin { val autoImport = Imports } @@ -84,6 +91,7 @@ object S extends AutoPlugin override def trigger = noTrigger override def projectSettings = Seq( - del in q += " S" + del in q += " S", + organization := "S" ) } diff --git a/sbt/src/sbt-test/project/auto-plugins/test b/sbt/src/sbt-test/project/auto-plugins/test index b1ab83bf7..518ca1bec 100644 --- a/sbt/src/sbt-test/project/auto-plugins/test +++ b/sbt/src/sbt-test/project/auto-plugins/test @@ -1,2 +1,3 @@ > plugins +> inspect organization > check