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

Set gitTagToVersionNumber per-project in a multi-project build #144

Open
maffoo opened this issue Sep 26, 2017 · 3 comments
Open

Set gitTagToVersionNumber per-project in a multi-project build #144

maffoo opened this issue Sep 26, 2017 · 3 comments

Comments

@maffoo
Copy link

maffoo commented Sep 26, 2017

In a project I am working on we have a mono-repo that includes various subprojects that are versioned and released separately. We'd like to switch to using sbt-git for these versions, so that for example we could use tags like Project1-vA.B.C to get the version of Project1 and Project2-vX.Y.Z to get the version of Project2.

However, it seems there is no convenient way to change the gitTagToVersionNumber setting for different projects within a multi-project build because the setting exposed by the plugin is explicitly scoped to ThisBuild. To get this to work I had to essentially copy the version setting into my build definition, but modify it to refer to the com.typesafe.sbt.SbtGit.GitKeys.gitTagToVersionNumber directly, instead of git.gitTagToVersionNumber which is scoped to ThisBuild.

I wonder if there's a way to make this work more cleanly without otherwise changing the way the plugin works by default. In particular, it seems to me that the setting implementations for things like version should refer to the underlying keys and let scope delegation handle the rest, rather than referring to explicitly globally-scoped keys. However, I'll admit that scoping and delegation can be confusing so this might have some downside I can't see.

@oliverlockwood
Copy link
Contributor

Heartily seconded!

There's some commonality between this and the issue I raised back in June (#133) - I have been wanting exactly the same thing but was initially focused on the first blocker.

@maffoo would you be able to share some more details (perhaps an example?) of your workaround in the meantime?

@maffoo
Copy link
Author

maffoo commented Oct 12, 2017

@oliverlockwood I literally had to just copy the version setting code from the plugin into my build and modify it slightly to scope it to the project instead of ThisBuild. For various other reasons, I've actually switched to just shelling out to git instead of using this plugin at all. Sadly...

@dwijnand
Copy link
Member

In particular, it seems to me that the setting implementations for things like version should refer to the underlying keys and let scope delegation handle the rest, rather than referring to explicitly globally-scoped keys. However, I'll admit that scoping and delegation can be confusing so this might have some downside I can't see.

I very much agree with you. The "downside" is that sbt's settings/scopes just don't work like that. I've filed that issue as sbt/sbt#2899.

I think we could resolve this issue by defining a new opt-in GitPerProjectVersioning AutoPlugin which defines things in project scope instead of build scope, then you can redefine gitTagToVersionNumber per-project. Pull requests welcome.

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

No branches or pull requests

3 participants