Merge pull request #8412 from anatoliykmetyuk/fix/issue-8405-updatesbtclassifiers-includes-plugins

Fix #8405 updateSbtClassifiers plugins output
This commit is contained in:
eugene yokota 2025-12-10 23:35:18 -05:00 committed by GitHub
commit 4ef942e7e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 49 additions and 1 deletions

View File

@ -203,8 +203,12 @@ private[sbt] object LibraryManagement {
case Left(w) =>
throw w.resolveException
}
val key = (m: ModuleID) => (m.organization, m.name, m.revision)
val originalKeys = dependencies.map(key).toSet
val transitiveOnly = report.allModules.filterNot(m => originalKeys contains key(m))
val mergedDependencies = dependencies ++ transitiveOnly
val newConfig = config
.withModule(module.withDependencies(report.allModules))
.withModule(module.withDependencies(mergedDependencies))
lm.updateClassifiers(newConfig, uwconfig, Vector(), log)
}

View File

@ -0,0 +1,32 @@
ivyConfiguration := Def.uncached {
throw new RuntimeException("updateSbtClassifiers should use updateSbtClassifiers / ivyConfiguration")
}
dependencyResolution := Def.uncached {
throw new RuntimeException("updateSbtClassifiers should use updateSbtClassifiers / dependencyResolution")
}
lazy val root = (project in file("."))
.settings(
scalaVersion := "2.11.12",
scalaOrganization := "doesnt.exist",
name := "myProjectName",
TaskKey[Unit]("checkPluginsInUpdateSbtClassifiers") := Def.uncached {
val updateReport = updateSbtClassifiers.value
val moduleReports = updateReport.configurations.find(_.configuration.name == "default").get.modules
// Calling "distinct" as there are different entries for sources and javadoc classifiers with same module
val moduleIds = moduleReports.map(_.module).distinct
val moduleIdsShort = moduleIds.map(m => s"${m.organization}:${m.name}")
// Verify that the target plugin sbt-buildinfo is included in the output
// The plugin may be cross-versioned as sbt-buildinfo_sbt2_3, etc.
val hasBuildinfoPlugin = moduleIdsShort.exists(id => id.startsWith("com.eed3si9n:sbt-buildinfo"))
assert(
hasBuildinfoPlugin,
s"Plugin com.eed3si9n:sbt-buildinfo was not found in updateSbtClassifiers output. Found modules: ${moduleIdsShort.sorted.mkString(", ")}"
)
}
)

View File

@ -0,0 +1,2 @@
ThisBuild / pluginCrossBuild / sbtVersion := "2.0.0"

View File

@ -0,0 +1,3 @@
// Add a plugin to test that it's included in updateSbtClassifiers output
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.13.1")

View File

@ -0,0 +1,5 @@
> updateSbtClassifiers
# see assertion definition in build.sbt
> checkPluginsInUpdateSbtClassifiers

View File

@ -39,11 +39,13 @@ lazy val root = (project in file("."))
"com.swoval:file-tree-views",
"com.typesafe:config",
"com.typesafe:ssl-config-core_3",
"junit:junit",
"net.java.dev.jna:jna",
"net.java.dev.jna:jna-platform",
"net.openhft:zero-allocation-hashing",
"org.checkerframework:checker-qual",
"org.fusesource.jansi:jansi",
"org.hamcrest:hamcrest-core",
"org.jline:jline-builtins",
"org.jline:jline-native",
"org.jline:jline-reader",