Gradle subproject versioning

2.8k views Asked by At

We are currently migrating our project from maven to gradle. Our setup looks like this:

  • Parent pom project
    • Subproject 1
    • Subproject 2 (compile depends 1)
    • Subproject 3 (compile depends on 2 and 1)

All these maven subprojects are independently versioned

With Maven, we are using version plugin, which ensures that we set (using the plugin) version of for example subproject 1, the new version is propagated to the whole subtree (and respective dependencies in 2 and 3 are changed as well).

I was looking to docs of gradle release plugin bud was not able to find a mention about this functinality. Does it support it, or is there any other plugin, which does?

Second question, as we are in the middle of the maven-gradle migration, is it possible to combine somehow maven version plugin with any such gradle plugin? (Have 1 versioned in maven, 2 and 3 in gradle and still achieve the behavior). My guess is not, but just asking, if someone have not found some solution :-), so we do not have to do maven -> gradle in one big bang.

Thanks in advance!

1

There are 1 answers

2
lance-java On BEST ANSWER

I like to keep my version in a separate text file

root/build.gradle

def versionTxt = file('version.txt').text.trim()
allprojects {
    version = versionTxt
}

Then you can just tweak version.txt to increment the version... this separation is great eg you can do a file history on version.txt and see the version changes isolated from gradle changes.

Single project example here