-
Notifications
You must be signed in to change notification settings - Fork 928
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
Write sbt.version to project/build.properties #3025
Conversation
Have sbt.version set in project/build.properties is a best practice because it makes the build more deterministic and reproducible. With this change sbt, after ensuring that the base directory is probably an sbt project, writes out sbt.version in project/build.properties if it is missing. Fixes sbt#754
private def isSbtProject(baseDir: File, projectDir: File) = | ||
projectDir.exists() || (baseDir * "*.sbt").get.nonEmpty | ||
|
||
private def setSbtVersion(baseDir: File, sbtVersion: String) = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to put opt-out Java flag around this method.
main/src/main/scala/sbt/Main.scala
Outdated
try { | ||
if (isSbtProject(baseDir, projectDir)) { | ||
val newBuildPropsLines = s"sbt.version=$sbtVersion" :: buildPropsLines | ||
IO.writeLines(buildProps, newBuildPropsLines) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think sbt should tell the user that it's writing the file. Software should not perform side effects silently without explicit user consent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Between not booting up at all and creating build.properties
, creating build.properties
I think is lesser of two bad scenarios.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. My point is that sbt should also say "don't worry, I'll write it out for you".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I don't have a strong opinion on displaying warning or silently creating the file. We can go either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good, because I agree with Martin.
Have sbt.version set in project/build.properties is a best practice
because it makes the build more deterministic and reproducible.
With this change sbt, after ensuring that the base directory is probably
an sbt project, writes out sbt.version in project/build.properties if it
is missing.
Fixes #754