How to achieve indepedent multi module versioning with sbt-release plugin

我的梦境 提交于 2019-12-11 03:19:42

问题


I have a two sub-projects and top level project which agreegates them. I can successfully release all of them but only version on top level project is changed and sub-projects are released with the version defined in their directory which unfortunately is not changed during release.

Root
|
 -SubA
|   |- version.sbt -> version in SubA := "0.0.1-SNAPSHOT"
|
 -SubB
|   |- version.sbt -> version in SubB := "0.0.4-SNAPSHOT"
|- version.sbt -> version in ThisBuild := "0.1.0-SNAPSHOT"

After release I would like to have:

  • Root released as 0.1.0 (although I don't care about the root at all)
  • SubA released as 0.0.1
  • SubB released as 0.0.4

and each version is incremeted for example in SubA/version.sbt -> 0.0.2-SNAPSHOT

How can I do that using sbt 0.13 and sbt-release plugin?


回答1:


You need to override the default location of the version.sbt file in each build.sbt of your submodule:

import ReleaseKeys._

organization := "com.organization"

name := "moduleName"

version := (version in ThisBuild).value

scalaVersion := "2.11.6"

releaseSettings

versionFile := file(name.value + "/version.sbt")

By default, version.sbt is located at the ROOT folder by sbt-release.




回答2:


Make a separate class/object and define a commonSettings lazy val, and set the version := {your_docker_version) there (you can override this value in different ways e.g. via System.property etc.
Then use this commonSettings in all of your Modules.



来源:https://stackoverflow.com/questions/25746376/how-to-achieve-indepedent-multi-module-versioning-with-sbt-release-plugin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!