8000 [1.9.x] Make loading order alphabetical for plugins by eed3si9n · Pull Request #7412 · sbt/sbt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[1.9.x] Make loading order alphabetical for plugins #7412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions main/src/main/scala/sbt/Plugins.scala
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ object Plugins extends PluginsFunctions {
case Right(results) =>
log.debug(s" :: deduced result: ${results}")
val selectedAtoms: List[Atom] = results.ordered
val selectedPlugins = selectedAtoms map { a =>
val selectedPlugins = (selectedAtoms map { a =>
byAtomMap.getOrElse(
a,
throw AutoPluginException(s"${a} was not found in atom map.")
)
}
}).sortBy(_.getClass.getName)
val forbidden: Set[AutoPlugin] =
(selectedPlugins flatMap { Plugins.asExclusions }).toSet
val c = selectedPlugins.toSet & forbidden
Expand Down
6 changes: 3 additions & 3 deletions main/src/test/scala/PluginsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object PluginsTest extends verify.BasicTestSuite {
assertEquals(
s"""Contradiction in enabled plugins:
- requested: sbt.AI$$S
- enabled: sbt.AI$$S, sbt.AI$$Q, sbt.AI$$R, sbt.AI$$B, sbt.AI$$A
- enabled: sbt.AI$$A, sbt.AI$$B, sbt.AI$$Q, sbt.AI$$R, sbt.AI$$S
- conflict: sbt.AI$$R is enabled by sbt.AI$$Q; excluded by sbt.AI$$S""",
e.message
)
Expand All @@ -63,8 +63,8 @@ object PluginsTest extends verify.BasicTestSuite {
assertEquals(
s"""Contradiction in enabled plugins:
- requested: sbt.AI$$T && sbt.AI$$U
- enabled: sbt.AI$$U, sbt.AI$$T, sbt.AI$$A, sbt.AI$$Q, sbt.AI$$R, sbt.AI$$B
- conflict: sbt.AI$$Q is enabled by sbt.AI$$A && sbt.AI$$B; required by sbt.AI$$T, sbt.AI$$R; excluded by sbt.AI$$U
- enabled: sbt.AI$$A, sbt.AI$$B, sbt.AI$$Q, sbt.AI$$R, sbt.AI$$T, sbt.AI$$U
- conflict: sbt.AI$$Q is enabled by sbt.AI$$A && sbt.AI$$B; required by sbt.AI$$R, sbt.AI$$T; excluded by sbt.AI$$U
- conflict: sbt.AI$$R is enabled by sbt.AI$$Q; excluded by sbt.AI$$T""",
e.message
)
Expand Down
65 changes: 33 additions & 32 deletions sbt-app/src/sbt-test/project/auto-plugins/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,38 @@ lazy val projI = project.enablePlugins(TopC)
lazy val disableAutoNoRequirePlugin = project.disablePlugins(OrgPlugin)

check := {
// 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")

// Ensure with multiple .sbt files that disabling/enabling works across them
val fDel = (del in Quux in projF).?.value
same(fDel, Some(" Q"), "del in Quux in projF")
//
val adel = (del in projA).?.value // should be None
same(adel, None, "del in projA")
val bdel = (del in projB).?.value // should be None
same(bdel, None, "del in projB")
val ddel = (del in projD).?.value // should be None
same(ddel, None, "del in projD")
//
val buildValue = (demo in ThisBuild).value
same(buildValue, "build 0", "demo in ThisBuild")
val globalValue = (demo in Global).value
same(globalValue, "global 0", "demo in Global")
val projValue = (demo in projC).?.value
same(projValue, Some("project projC Q R"), "demo in projC")
val qValue = (del in projC in Quux).?.value
same(qValue, Some(" Q R"), "del in projC in Quux")
val optInValue = (del in projE in Quux).value
same(optInValue, " Q S R", "del in projE in Quux")
val overrideOrgValue = (organization in projE).value
same(overrideOrgValue, "S", "organization in projE")
// tests for top level plugins
// 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")

// Ensure with multiple .sbt files that disabling/enabling works across them
val fDel = (del in Quux in projF).?.value
same(fDel, Some(" Q"), "del in Quux in projF")

val adel = (del in projA).?.value // should be None
same(adel, None, "del in projA")
val bdel = (del in projB).?.value // should be None
same(bdel, None, "del in projB")
val ddel = (del in projD).?.value // should be None
same(ddel, None, "del in projD")

val buildValue = (demo in ThisBuild).value
same(buildValue, "build 0", "demo in ThisBuild")
val globalValue = (demo in Global).value
same(globalValue, "global 0", "demo in Global")
val projValue = (demo in projC).?.value
same(projValue, Some("project projC Q R"), "demo in projC")
val qValue = (del in projC in Quux).?.value
same(qValue, Some(" Q R"), "del in projC in Quux")
val optInValue = (del in projE in Quux).value
same(optInValue, " Q R S", "del in projE in Quux")
val overrideOrgValue = (organization in projE).value
same(overrideOrgValue, "S", "organization in projE")

// tests for top level plugins
val topLevelAValueG = (topLevelDemo in projG).value
same(topLevelAValueG, "TopA: topLevelDemo project projG", "topLevelDemo in projG")
val demoValueG = (demo in projG).value
Expand All @@ -75,5 +76,5 @@ keyTest := "foo"
topLevelKeyTest := "bar"

def same[T](actual: T, expected: T, label: String): Unit = {
assert(actual == expected, s"Expected '$expected' for `$label`, got '$actual'")
assert(actual == expected, s"Expected '$expected' for `$label`, got '$actual'")
}
0