@@ -381,10 +381,42 @@ trait MillPublishJavaModule extends MillJavaModule with PublishModule {
381381 def javacOptions = Seq("-source", "1.8", "-target", "1.8", "-encoding", "UTF-8")
382382}
383383
384+ /* Until scalafix-interfaces releases a version that can reflectively load Scalafix for
385+ * Scala 3, we need to skip Scalafix for Scala 3 modules.
386+ *
387+ * @see https://github.com/scalacenter/scalafix/blob/24078c391ae1f9e823489afe008318bcc13ae90d/scalafix-interfaces/src/main/java/scalafix/interfaces/Scalafix.java#L133
388+ */
389+ trait SkipScalafix extends ScalafixModule { self: ScalaModule =>
390+
391+ def fix(args: String*): Command[Unit] = T.command {
392+ if (scalaVersion().startsWith("3.")) {
393+ T.log.info(s"Skipping scalafix for Scala 3 module $self")
394+ mill.api.Result.Success(())
395+ } else {
396+ // copied from ScalafixModule.fix
397+ // @note - not sure if there is a way to call super.fix(args: _*) directly
398+ // when we want boolean condition to skip the command
399+ ScalafixModule.fixAction(
400+ T.ctx().log,
401+ repositoriesTask(),
402+ ScalafixModule.filesToFix(sources()).map(_.path),
403+ classpath = (compileClasspath() ++ localClasspath() ++ Seq(semanticDbData())).iterator.toSeq.map(_.path),
404+ scalaVersion(),
405+ scalafixScalaBinaryVersion(),
406+ scalacOptions(),
407+ scalafixIvyDeps(),
408+ scalafixConfig(),
409+ args,
410+ T.workspace
411+ )
412+ }
413+ }
414+ }
415+
384416/**
385417 * Some custom scala settings and test convenience
386418 */
387- trait MillScalaModule extends ScalaModule with MillJavaModule with ScalafixModule { outer =>
419+ trait MillScalaModule extends ScalaModule with MillJavaModule with SkipScalafix { outer =>
388420 def scalaVersion = Deps.scalaVersion
389421 def scalapVersion = T { Deps.scala2Version }
390422 def scalafixScalaBinaryVersion = ZincWorkerUtil.scalaBinaryVersion(scalaVersion())
0 commit comments