jsuereth / sbt-in-action-examples

Source code examples for the book "sbt in Action"
144 stars 54 forks source link

Versioning problems - sbt-git plugin's versionWithGit & git.baseVersion does not work #14

Open nightwolfzor opened 9 years ago

nightwolfzor commented 9 years ago

Looks like some of the examples are a bit broken in Ch12 (also ch10).

We have git.baseVersion := "0.1"

Then in our def PreownedKittenProject we have .settings(versionWithGit:_*)

This does not work, when running sbt version we see something like 1.0-gitSha... Not 0.1-gitSha...

Also the version.properties file val content = "version=%s" format (gitHeadCommitSha.value) is just using the gitHeadCommitSha not the value from the sbt-git plugin... This gives inconsistent versions. I will agree that it makes it nicer as you dont need to reload the project on each commit to get the version.properties file updated but its a big inconsistency.

versionWithGit seems to be the way to go, so it would be nice to have this working consistently...

I think git.baseVersion := "0.1" should be a part of the settings block in the def PreownedKittenProject(name: String) block (where organization is defined)...

How to use this in the version.properties file I'm not sure... Changing to val content = "version=%s" format (version.value) will work but it wont pickup changes when committing without doing a sbt reload which is a hassle... We need some taskKey to update the version value... I'm not that far through the book so not sure where to start on this one...

WorkDayHeyHey commented 9 years ago

I am trying to use this for my builds too and find that it works sometimes.

If I load and enter version I get git.baseVersion+SHA, even though I have previously tagged versions, that I see if I enter git tag.

If I "release v#.#" and then run version I see that version. If I release V#.#+1, the tag is added to git but the jar (I am using assemly) is versioned with the first tag of the session and version also shows the first tag also.

If I exit I come back to base+SHA

WorkDayHeyHey commented 9 years ago

also:

knows about at least the latest tags: > gitCurrentTags [info] List(v0.4, v0.5)

and if I add useJGit then >version shows the oldest of the two