From 0e872d79e2ca75047ea66e017409e873547fcd78 Mon Sep 17 00:00:00 2001 From: Matthias Kurz Date: Fri, 18 Sep 2026 15:57:39 +0200 Subject: [PATCH] build: replace external dependency graph plugin #452 Motivation: The legacy sbt-dependency-graph plugin is no longer needed because dependency-tree support is available in sbt itself. Modification: Use addDependencyTreePlugin and derive PR validation module IDs directly from public UpdateReport data instead of legacy plugin graph types. Result: The build uses sbt 1.13 dependency-tree support while preserving PR impact analysis without obsolete plugin APIs. Tests: - sbt -batch "show sbtVersion" (passed; meta-build compiled with sbt 1.13.0) - Test suites not run per request. References: Fixes #452 --- project/ValidatePullRequest.scala | 28 ++++++++++++++-------------- project/plugins.sbt | 3 ++- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/project/ValidatePullRequest.scala b/project/ValidatePullRequest.scala index 9d8ddddc4..87bd4c41f 100644 --- a/project/ValidatePullRequest.scala +++ b/project/ValidatePullRequest.scala @@ -14,8 +14,6 @@ import java.io._ import MimaWithPrValidation.{ MimaResult, NoErrors, Problems } -import net.virtualvoid.sbt.graph.ModuleGraph -import net.virtualvoid.sbt.graph.backend.SbtUpdateReport import org.kohsuke.github.GHIssueComment import org.kohsuke.github.GitHubBuilder import sbt.Keys._ @@ -113,17 +111,17 @@ object ValidatePullRequest extends AutoPlugin { val BuildFilesAndDirectories = Set("project", "build.sbt", ".github") def changedDirectoryIsDependency(changedDirs: Set[String], name: String, - graphsToTest: Seq[(Configuration, ModuleGraph)])(log: Logger): Boolean = { + dependenciesToTest: Seq[(Configuration, Seq[ModuleID])])(log: Logger): Boolean = { val dirsOrExperimental = changedDirs.flatMap(dir => Set(dir, s"$dir-experimental")) - graphsToTest.exists { case (ivyScope, deps) => + dependenciesToTest.exists { case (ivyScope, dependencies) => log.debug(s"Analysing [$ivyScope] scoped dependencies...") - deps.nodes.foreach { m => log.debug(" -> " + m.id) } + dependencies.foreach { module => log.debug(" -> " + module) } // if this project depends on a modified module, we must test it - deps.nodes.exists { m => + dependencies.exists { module => // match just by name, we'd rather include too much than too little - val dependsOnModule = dirsOrExperimental.find(m.id.name contains _) + val dependsOnModule = dirsOrExperimental.find(module.name contains _) val depends = dependsOnModule.isDefined if (depends) log.info(s"Project [$name] must be verified, because depends on [${dependsOnModule.get}]") depends @@ -226,19 +224,21 @@ object ValidatePullRequest extends AutoPlugin { val thisProjectId = CrossVersion(scalaVersion.value, scalaBinaryVersion.value)(projectID.value) - def graphFor(updateReport: UpdateReport, config: Configuration): (Configuration, ModuleGraph) = - config -> SbtUpdateReport.fromConfigurationReport(updateReport.configuration(config).get, thisProjectId) + def dependenciesFor(updateReport: UpdateReport, config: Configuration): (Configuration, Seq[ModuleID]) = { + val dependencies = updateReport.configuration(config).get.details.flatMap(_.modules).map(_.module) + config -> (thisProjectId +: dependencies) + } def isDependency: Boolean = { changedDirectoryIsDependency( changedDirs, name.value, Seq( - graphFor((Compile / updateFull).value, Compile), - graphFor((Test / updateFull).value, Test), - graphFor((Runtime / updateFull).value, Runtime), - graphFor((Provided / updateFull).value, Provided), - graphFor((Optional / updateFull).value, Optional)))(log) + dependenciesFor((Compile / updateFull).value, Compile), + dependenciesFor((Test / updateFull).value, Test), + dependenciesFor((Runtime / updateFull).value, Runtime), + dependenciesFor((Provided / updateFull).value, Provided), + dependenciesFor((Optional / updateFull).value, Optional)))(log) } if (githubCommandEnforcedBuildAll.isDefined) diff --git a/project/plugins.sbt b/project/plugins.sbt index cab6ca19d..bf8193d6a 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -9,6 +9,8 @@ resolvers += Classpaths.sbtPluginReleases +addDependencyTreePlugin + addSbtPlugin("com.github.sbt" % "sbt-multi-jvm" % "0.7.0") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.2.0") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.6.2") @@ -16,7 +18,6 @@ addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.1.1") addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.6.1") addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.3") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.8") -addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.10.0-RC1") // for advanced PR validation features addSbtPlugin("com.github.sbt" % "sbt-boilerplate" % "0.8.1") addSbtPlugin("com.lightbend.sbt" % "sbt-bill-of-materials" % "1.1.1") addSbtPlugin("com.github.sbt" % "sbt-license-report" % "1.10.0")