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

Write sbt.version to project/build.properties #3025

Merged
merged 3 commits into from
Mar 17, 2017

Conversation

dwijnand
Copy link
Member

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

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) = {
Copy link
Member

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.

try {
if (isSbtProject(baseDir, projectDir)) {
val newBuildPropsLines = s"sbt.version=$sbtVersion" :: buildPropsLines
IO.writeLines(buildProps, newBuildPropsLines)
Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor

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".

Copy link
Member

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.

Copy link
Member Author

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.

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 this pull request may close these issues.

None yet

3 participants