diff --git a/src/main/scala-sbt-1.0/scalafix/sbt/ScalafixTestkitPlugin.scala b/src/main/scala-sbt-1.0/scalafix/sbt/ScalafixTestkitPlugin.scala index b23bb967..b8290c77 100644 --- a/src/main/scala-sbt-1.0/scalafix/sbt/ScalafixTestkitPlugin.scala +++ b/src/main/scala-sbt-1.0/scalafix/sbt/ScalafixTestkitPlugin.scala @@ -13,38 +13,42 @@ object ScalafixTestkitPlugin extends AutoPlugin { override def requires: Plugins = JvmPlugin object autoImport { - case class InputAxis(scalaVersion: String) extends VirtualAxis.WeakAxis { + case class TestkitTargetAxis(scalaVersion: String) + extends VirtualAxis.WeakAxis { private val scalaBinaryVersion = CrossVersion.binaryScalaVersion(scalaVersion) - override val idSuffix = s"Input${scalaBinaryVersion.replace('.', '_')}" - override val directorySuffix = s"input$scalaBinaryVersion" + override val idSuffix = s"Target${scalaBinaryVersion.replace('.', '_')}" + override val directorySuffix = s"target$scalaBinaryVersion" } - object InputAxis { - def inputScalaVersion(virtualAxes: Seq[VirtualAxis]): String = - virtualAxes.collectFirst { case a: InputAxis => a.scalaVersion }.get - } + object TestkitTargetAxis { - def resolveByInputAxis[T]( - matrix: ProjectMatrix, - key: TaskKey[T] - ): Def.Initialize[Task[T]] = - Def.taskDyn { - val sv = InputAxis.inputScalaVersion(virtualAxes.value) - val project = matrix.finder().apply(sv) - Def.task((project / key).value) - } + private def targetScalaVersion(virtualAxes: Seq[VirtualAxis]): String = + virtualAxes.collectFirst { case a: TestkitTargetAxis => + a.scalaVersion + }.get - def resolveByInputAxis[T]( - matrix: ProjectMatrix, - key: SettingKey[T] - ): Def.Initialize[T] = - Def.settingDyn { - val sv = InputAxis.inputScalaVersion(virtualAxes.value) - val project = matrix.finder().apply(sv) - Def.setting((project / key).value) - } + def resolve[T]( + matrix: ProjectMatrix, + key: TaskKey[T] + ): Def.Initialize[Task[T]] = + Def.taskDyn { + val sv = targetScalaVersion(virtualAxes.value) + val project = matrix.finder().apply(sv) + Def.task((project / key).value) + } + + def resolve[T]( + matrix: ProjectMatrix, + key: SettingKey[T] + ): Def.Initialize[T] = + Def.settingDyn { + val sv = targetScalaVersion(virtualAxes.value) + val project = matrix.finder().apply(sv) + Def.setting((project / key).value) + } + } val scalafixTestkitInputClasspath = taskKey[Classpath]("Classpath of input project") @@ -80,7 +84,7 @@ object ScalafixTestkitPlugin extends AutoPlugin { "inputClasspath" -> scalafixTestkitInputClasspath.value.map(_.data), "inputSourceDirectories" -> - scalafixTestkitInputSourceDirectories.value, + scalafixTestkitInputSourceDirectories.value.distinct, // https://github.com/sbt/sbt/pull/6511 "outputSourceDirectories" -> scalafixTestkitOutputSourceDirectories.value ) diff --git a/src/sbt-test/sbt-1.5/testkit/build.sbt b/src/sbt-test/sbt-1.5/testkit/build.sbt index 1b93899f..70884a86 100644 --- a/src/sbt-test/sbt-1.5/testkit/build.sbt +++ b/src/sbt-test/sbt-1.5/testkit/build.sbt @@ -38,40 +38,41 @@ lazy val tests = projectMatrix .settings( libraryDependencies += "ch.epfl.scala" % "scalafix-testkit" % V.scalafixVersion % Test cross CrossVersion.full, scalafixTestkitOutputSourceDirectories := - resolveByInputAxis(output, Compile / unmanagedSourceDirectories).value, + TestkitTargetAxis + .resolve(output, Compile / unmanagedSourceDirectories) + .value, scalafixTestkitInputSourceDirectories := - resolveByInputAxis( - input, - Compile / unmanagedSourceDirectories - ).value.distinct, // https://github.com/sbt/sbt/pull/6511 + TestkitTargetAxis + .resolve(input, Compile / unmanagedSourceDirectories) + .value, scalafixTestkitInputClasspath := - resolveByInputAxis(input, Compile / fullClasspath).value, + TestkitTargetAxis.resolve(input, Compile / fullClasspath).value, scalafixTestkitInputScalacOptions := - resolveByInputAxis(input, Compile / scalacOptions).value, + TestkitTargetAxis.resolve(input, Compile / scalacOptions).value, scalafixTestkitInputScalaVersion := - resolveByInputAxis(input, Compile / scalaVersion).value + TestkitTargetAxis.resolve(input, Compile / scalaVersion).value ) .defaultAxes( rulesCrossVersions.map(VirtualAxis.scalaABIVersion) :+ VirtualAxis.jvm: _* ) .customRow( scalaVersions = Seq(V.scala212), - axisValues = Seq(InputAxis(scala3Version), VirtualAxis.jvm), + axisValues = Seq(TestkitTargetAxis(scala3Version), VirtualAxis.jvm), settings = Seq() ) .customRow( scalaVersions = Seq(V.scala213), - axisValues = Seq(InputAxis(V.scala213), VirtualAxis.jvm), + axisValues = Seq(TestkitTargetAxis(V.scala213), VirtualAxis.jvm), settings = Seq() ) .customRow( scalaVersions = Seq(V.scala212), - axisValues = Seq(InputAxis(V.scala212), VirtualAxis.jvm), + axisValues = Seq(TestkitTargetAxis(V.scala212), VirtualAxis.jvm), settings = Seq() ) .customRow( scalaVersions = Seq(V.scala211), - axisValues = Seq(InputAxis(V.scala211), VirtualAxis.jvm), + axisValues = Seq(TestkitTargetAxis(V.scala211), VirtualAxis.jvm), settings = Seq() ) .dependsOn(rules) diff --git a/src/sbt-test/sbt-1.5/testkit/test b/src/sbt-test/sbt-1.5/testkit/test index 6e9eb333..41dbb51c 100644 --- a/src/sbt-test/sbt-1.5/testkit/test +++ b/src/sbt-test/sbt-1.5/testkit/test @@ -1,3 +1,3 @@ -> tests/test -> testsInput3/test:run --save-expect +> testsTarget3/test:run --save-expect > tests/test