Skip to content
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

Scalafmt on compile races with scaladoc #90

Closed
nigredo-tori opened this issue Apr 10, 2020 · 1 comment · Fixed by #91
Closed

Scalafmt on compile races with scaladoc #90

nigredo-tori opened this issue Apr 10, 2020 · 1 comment · Fixed by #91

Comments

@nigredo-tori
Copy link
Contributor

This one is tricky to reproduce. I think I've seen it in one of my CI builds (with scalafmt on compile) - the doc task has failed, citing missing types from the same project - but it was gone after I've restarted the build. I'm fairly certain that the reason is as follows.

At the moment, Scalafmt is wired into the compile / compileInputs task, which relies on client / Compile / sources:

sbt:root> inspect tree client/compile/compileInputs
[info] client / Compile / compile / compileInputs = Task[xsbti.compile.Inputs]
...
[info]   +-client / Compile / compile / compileOptions = Task[xsbti.compile.C..
...
[info]   | +-client / Compile / sources = Task[scala.collection.Seq[java.io.F..
...
[info]   +-client / Compile / scalafmtDoFormatOnCompile = Task[Unit]
[info]     +-ThisBuild / scalafmtOnCompile = true

However, the Scaladoc build (the Compile / doc task) directly uses Compile / sources instead:

sbt:root> inspect tree client/doc
[info] client / Compile / doc = Task[java.io.File]
...
[info]   +-client / Compile / sources = Task[scala.collection.Seq[java.io.Fil..

This means that we can have client / Compile / doc and scalafmtDoFormatOnCompile running in parallel. If formatting changes the sources (in my case that was caused by Windows line endings), client / Compile / doc can observe partially regenerated sources, which is problematic.

I suggest we wire formatting directly into Compile / sources instead.

@poslegm
Copy link
Collaborator

poslegm commented Apr 10, 2020

Published v2.3.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants