Skip to content

Commit

Permalink
WIP: working sbt 2.x version
Browse files Browse the repository at this point in the history
  • Loading branch information
hugo-vrijswijk committed Dec 18, 2024
1 parent 1c2cfa0 commit 6ad20ab
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
37 changes: 19 additions & 18 deletions modules/sbt/src/main/scala/stryker4s/sbt/Stryker4sPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ object Stryker4sPlugin extends AutoPlugin {
} yield s"$base/$path"
}

lazy val strykerTask = Def.inputTaskDyn {
lazy val strykerTask = Def.inputTask {
// Call logLevel so it shows up as a used setting when set
val _ = (stryker / logLevel).value
val sbtLog = streams.value.log
Expand All @@ -137,23 +137,24 @@ object Stryker4sPlugin extends AutoPlugin {

val sbtConfig = SbtConfigSource[IO]().value

Def.task {
implicit val runtime: IORuntime = IORuntime.global
implicit val logger: Logger = new SbtLogger(sbtLog)
implicit val conv: FileConverter = fileConverter.value
val parsed = sbt.complete.DefaultParsers.spaceDelimited("<arg>").parsed
val cliConfig = new CliConfigSource(parsed)
val extraConfigSources = List(sbtConfig, cliConfig)

Deferred[IO, FiniteDuration] // Create shared timeout between testrunners
.map(new Stryker4sSbtRunner(state.value, _, extraConfigSources))
.flatMap(_.run())
.flatMap {
case ErrorStatus => IO.raiseError(new MessageOnlyException("Mutation score is below configured threshold"))
case _ => IO.unit
}
.unsafeRunSync()
}
// TODO: uncomment when inputTaskDyn is implemented in sbt 2.x https://github.com/sbt/sbt/issues/7707
// Def.task {
implicit val runtime: IORuntime = IORuntime.global
implicit val logger: Logger = new SbtLogger(sbtLog)
implicit val conv: FileConverter = fileConverter.value
val parsed = sbt.complete.DefaultParsers.spaceDelimited("<arg>").parsed
val cliConfig = new CliConfigSource(parsed)
val extraConfigSources = List(sbtConfig, cliConfig)

Deferred[IO, FiniteDuration] // Create shared timeout between testrunners
.map(new Stryker4sSbtRunner(state.value, _, extraConfigSources))
.flatMap(_.run())
.flatMap {
case ErrorStatus => IO.raiseError(new MessageOnlyException("Mutation score is below configured threshold"))
case _ => IO.unit
}
.unsafeRunSync()
// }
}

private class UnsupportedSbtVersionException(s: String)
Expand Down
15 changes: 15 additions & 0 deletions project/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ object Settings {
scriptedLaunchOpts.value ++
Seq("-Xmx1024M", "-Dplugin.version=" + version.value)
},
tpolecatExcludeOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) =>
Set(
// TODO: remove when https://github.com/sbt/sbt/issues/7726 is fixed
ScalacOptions.warnUnusedImplicits,
ScalacOptions.warnUnusedImports,
ScalacOptions.warnUnusedLocals,
ScalacOptions.warnUnusedParams,
ScalacOptions.warnUnusedPatVars,
ScalacOptions.warnUnusedPrivates,
ScalacOptions.warnUnusedExplicits,
ScalacOptions.warnUnusedNoWarn
)
case _ => Set.empty
}),
(pluginCrossBuild / sbtVersion) := {
scalaBinaryVersion.value match {
case "2.12" => "1.7.0"
Expand Down

0 comments on commit 6ad20ab

Please sign in to comment.