-
-
Notifications
You must be signed in to change notification settings - Fork 296
-
At work, I am currently trying to set up commitizen on a handful of Java libraries and am not sure the best option to choose on cz init
regarding the source of the version.
- Maybe the commitizen config option would be fine, since I'm already adding the toml
npm
is out of the question since it seems unnecessary to have to add a package.json to a Java project- Also, eventually, I want to be able to have
cz
run in our Azure DevOps pipeline whenever we are creating a release fromdevelop
tomaster
This led me to consider extending the selections to include Maven's pom.xml
and be able to both get AND set the project.version
This seems possible by invoking maven directly from the command line via a subprocess in python:
import subprocess def run_cmd(command): return subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).stdout.read() version_cmd='mvn help:evaluate -Dexpression=project.version -q -DforceStdout' version = run_cmd(version_cmd) print(version.decode())
If this looks like an okay starting point, I can create a PR with a first stab at the commitizen/providers/maven_provider.py
file.
Not sure what else will need to update yet though, so any guidance would be welcome!
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
Hi! Thanks for this info, we recommend creating a new package for different version handlers.
Here's an example on how to build a custom version provider:
https://commitizen-tools.github.io/commitizen/config/#custom-version-provider
Beta Was this translation helpful? Give feedback.
All reactions
-
Hi @woile , thanks for the reference!
Few questions for you:
- Would this wire up Maven/mvn to be a choice on
cz init
? - Would your suggestion be the same or similar if we also wanted to add a new version scheme (basically SemVer plus a qualifier, like 3.2.1-SNAPSHOT)?
I looked into the code last night and was able to put together PR #963 just adding mvn
as an option on cz init
.
I'm still looking into adding a MavenVer
class in version_schemes
to handle the various java qualifiers.
I have been using this as a reference: https://octopus.com/blog/maven-versioning-explained
By the way, just wanted to say how lovely the code base and tooling setup is. This is my first time using most of these tools and it has been a great experience so far!
Beta Was this translation helpful? Give feedback.