Skip to content

Commit 7b5680a

Browse files
authored
Fix toolkit dependency updates (#2138)
1 parent 043f7ed commit 7b5680a

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

modules/integration/src/test/scala/scala/cli/integration/DependencyUpdateTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class DependencyUpdateTests extends ScalaCliSuite {
6161
}
6262
}
6363

64-
test("update typelevel toolkit dependence") {
64+
test("update typelevel toolkit dependency") {
6565
val toolkitVersion = "0.0.1"
6666
val testInputs = TestInputs(
6767
os.rel / "Foo.scala" ->
@@ -79,7 +79,7 @@ class DependencyUpdateTests extends ScalaCliSuite {
7979
os.proc(TestUtil.cli, "--power", "dependency-update", "--all", ".")
8080
.call(cwd = root)
8181

82-
val toolkitDirective = "//> using toolkit \"(.*)\"".r
82+
val toolkitDirective = "//> using toolkit \"typelevel:(.*)\"".r
8383
val updatedToolkitVersionOpt = {
8484
val regexMatch = toolkitDirective.findFirstMatchIn(os.read(root / "Foo.scala"))
8585
regexMatch.map(_.group(1))

modules/options/src/main/scala/scala/build/actionable/ActionableDependencyHandler.scala

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ package scala.build.actionable
33
import coursier.Versions
44
import coursier.core.{Latest, Version}
55
import coursier.parse.RepositoryParser
6-
import dependency._
6+
import dependency.*
77

88
import scala.build.EitherCps.{either, value}
99
import scala.build.Positioned
10-
import scala.build.actionable.ActionableDiagnostic._
10+
import scala.build.actionable.ActionableDiagnostic.*
1111
import scala.build.actionable.errors.ActionableHandlerError
1212
import scala.build.errors.{BuildException, RepositoryFormatError}
13-
import scala.build.internal.Util._
13+
import scala.build.internal.Constants
14+
import scala.build.internal.Util.*
1415
import scala.build.options.BuildOptions
1516
import scala.build.options.ScalaVersionUtil.versions
1617
import scala.concurrent.duration.DurationInt
@@ -32,15 +33,26 @@ case object ActionableDependencyHandler
3233
val dependency = setting.value
3334
val currentVersion = dependency.version
3435
val latestVersion = value(findLatestVersion(buildOptions, dependency))
35-
if (Version(latestVersion) > Version(currentVersion) && !isLatestSyntaxVersion(currentVersion))
36-
if (dependency.userParams.contains("toolkit"))
36+
if Version(latestVersion) > Version(currentVersion) && !isLatestSyntaxVersion(currentVersion)
37+
then
38+
if dependency.userParams.contains(Constants.toolkitName) &&
39+
dependency.module.name != Constants.toolkitTestName
40+
then
41+
val toolkitSuggestion =
42+
if dependency.module.organization == Constants.toolkitOrganization then latestVersion
43+
else if dependency.module.organization == Constants.typelevelOrganization then
44+
s"typelevel:$latestVersion"
45+
else s"${dependency.module.organization}:$latestVersion"
3746
Some(ActionableDependencyUpdateDiagnostic(
3847
setting.positions,
3948
currentVersion,
4049
latestVersion,
41-
dependencyModuleName = "toolkit",
42-
suggestion = latestVersion
50+
dependencyModuleName = Constants.toolkitName,
51+
suggestion = toolkitSuggestion
4352
))
53+
else if dependency.userParams.contains(Constants.toolkitName) &&
54+
dependency.module.name == Constants.toolkitTestName
55+
then None // filtering out toolkit-test to prevent double-update-diagnostic
4456
else
4557
Some(ActionableDependencyUpdateDiagnostic(
4658
setting.positions,

0 commit comments

Comments
 (0)