mirror of https://github.com/sbt/sbt.git
Allow autogenerated projects to have overridden organization.
* Change detection of "default project" to accurately see if someone has changed the organization. * Add a flag to notify downstream consumers that a project was autogenerated and not user specified. Fixes #1315
This commit is contained in:
parent
af70a895de
commit
68a2f57da9
|
|
@ -4,7 +4,7 @@
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import Keys.{ name, organization, thisProject }
|
import Keys.{ name, organization, thisProject, autoGeneratedProject }
|
||||||
import Def.{ ScopedKey, Setting }
|
import Def.{ ScopedKey, Setting }
|
||||||
|
|
||||||
// name is more like BuildDefinition, but that is too long
|
// 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.
|
// 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.
|
// if the user has overridden the name, use the normal organization that is derived from the name.
|
||||||
organization := {
|
organization := {
|
||||||
val overridden = thisProject.value.id == name.value
|
def isDefault(o: String) = thisProject.value.id == o
|
||||||
organization.?.value match {
|
organization.?.value match {
|
||||||
case Some(o) if !overridden => o
|
case Some(o) if !isDefault(o) => o
|
||||||
case _ => "default"
|
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 =
|
def defaultAggregatedProject(id: String, base: File, agg: Seq[ProjectRef]): Project =
|
||||||
defaultProject(id, base).aggregate(agg: _*)
|
defaultProject(id, base).aggregate(agg: _*)
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ object Keys {
|
||||||
val sLog = SettingKey[Logger]("setting-logger", "Logger usable by settings during project loading.", CSetting)
|
val sLog = SettingKey[Logger]("setting-logger", "Logger usable by settings during project loading.", CSetting)
|
||||||
|
|
||||||
// Project keys
|
// 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 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 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)
|
val stateBuildStructure = AttributeKey[BuildStructure]("build-structure", "Data structure containing all information about the build definition.", BSetting)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,10 @@ lazy val projF = project
|
||||||
disablePlugins(plugins.IvyPlugin)
|
disablePlugins(plugins.IvyPlugin)
|
||||||
|
|
||||||
check := {
|
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
|
val dversion = (projectID in projD).?.value // Should be None
|
||||||
same(dversion, None, "projectID in projD")
|
same(dversion, None, "projectID in projD")
|
||||||
val rversion = projectID.?.value // Should be None
|
val rversion = projectID.?.value // Should be None
|
||||||
|
|
@ -44,6 +47,8 @@ check := {
|
||||||
same(qValue, Some(" Q R"), "del in projC in q")
|
same(qValue, Some(" Q R"), "del in projC in q")
|
||||||
val optInValue = (del in projE in q).value
|
val optInValue = (del in projE in q).value
|
||||||
same(optInValue, " Q S R", "del in projE in q")
|
same(optInValue, " Q S R", "del in projE in q")
|
||||||
|
val overrideOrgValue = (organization in projE).value
|
||||||
|
same(overrideOrgValue, "S", "organization in projE")
|
||||||
}
|
}
|
||||||
|
|
||||||
keyTest := "foo"
|
keyTest := "foo"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package sbttest // you need package http://stackoverflow.com/questions/9822008/
|
package sbttest // you need package http://stackoverflow.com/questions/9822008/
|
||||||
|
|
||||||
import sbt._
|
import sbt._
|
||||||
import sbt.Keys.{name, resolvedScoped}
|
import sbt.Keys.{name, resolvedScoped, organization }
|
||||||
import java.util.concurrent.atomic.{AtomicInteger => AInt}
|
import java.util.concurrent.atomic.{AtomicInteger => AInt}
|
||||||
|
|
||||||
object Imports
|
object Imports
|
||||||
|
|
@ -19,6 +19,13 @@ object Imports
|
||||||
lazy val check = taskKey[Unit]("Verifies settings are as they should be.")
|
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 {
|
object X extends AutoPlugin {
|
||||||
val autoImport = Imports
|
val autoImport = Imports
|
||||||
}
|
}
|
||||||
|
|
@ -84,6 +91,7 @@ object S extends AutoPlugin
|
||||||
override def trigger = noTrigger
|
override def trigger = noTrigger
|
||||||
|
|
||||||
override def projectSettings = Seq(
|
override def projectSettings = Seq(
|
||||||
del in q += " S"
|
del in q += " S",
|
||||||
|
organization := "S"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
> plugins
|
> plugins
|
||||||
|
> inspect organization
|
||||||
> check
|
> check
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue