mirror of https://github.com/sbt/sbt.git
Merge pull request #1378 from sbt/wip/fix-default-generated-projects
Allow autogenerated projects to have overridden organization.
This commit is contained in:
commit
baf78797d6
|
|
@ -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: _*)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
> plugins
|
||||
> inspect organization
|
||||
> check
|
||||
|
|
|
|||
Loading…
Reference in New Issue