-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scalafix sbt task hangs when invoked as part of compile task #2008
Comments
Thanks for the report @bphold! This is clearly a regression of scalacenter/sbt-scalafix#411. I can't think of an easy way to fix that without reverting that PR... However, it looks like what you are trying to achieve can be done through a built-in feature. # build.sbt
scalafixOnCompile := true
Would that work for you? |
Yes, I think that works! I'm going to try re-updating some of the projects I downgraded from For background, many of our projects use an lazy val `generated-sources` = (project in file("generated-sources"))
.settings(
Compile / compile := Def.taskDyn {
val compileOutput = (Compile / compile).value
Def.task {
(Compile / scalafix).toTask(" AddCatsTaglessInstances").value
compileOutput
}
}.value,
)
lazy val `main-project` = project.in(file(".")).dependsOn(`generated-sources`) The Ideally we'd be able to run
As it exists today (both with our previous |
Glad to see you are back tracking the latest scalafix version 👍
Sorry it took me so long to answer, I wanted to have a deep look at it since my initial thought was that this was impossible... Unfortunately, my conclusion is that it's indeed impossible with the current sbt model, where a task dependency can only be evaluated once per task invocation. To achieve what you are describing, my recommendation would be to follow the pattern used by https://github.com/hamnis/dataclass-scalafix. Namely, to handle scalafix additions via a source generator declared hooked in In any case, I suggest we continue the discussion on #1674 if that's OK for you. |
Prior to Scalafix
0.12.1
, we had many repos where we apply Scalafix rules on everycompile
by chaining thescalafix
task as part of thecompile
task. As of0.12.1
, applying any semantic rules in this way causes sbt to hang in such a way that it can only be killed from the outside (e.g. usingkill -9 ${sbt pid}
).As a minimal example, use this
build.sbt
:project/plugins.sbt
:and
project/build.properties
:sbt.version=1.10.0
Example output:
If we comment out the
(Compile / scalafix).toTask(" ExplicitResultTypes").value
line inbuild.sbt
and run the tasks separately, they work fine:Furthermore, using one of the built-in syntactic rules works fine as well.
Replacing Scalafix
0.12.1
with0.12.0
also works fine.The text was updated successfully, but these errors were encountered: