Welcome to this jgitver gradle demo.
In this tutorial, you will see how to integrate jgitver into a Gradle project.
jgitver will allow automatic project version computation based on git information (tags, commits, branches, ...)
Without any modification in your build.gradle
file, jgitver will be able
to compute automatically the version
field of your project.
Using the provided defaults you could obtain the following versions:
For now let's move to the next slide.
You're done, you have successfully used jgitver and its jgitver gradle plugin: it was so easy, no?
Feel free now to:
- follow the other training scenarios
- consult the jgitver documentation
- ask questions and chat on gitter

Steps
jgitver on Gradle, an introduction using docker
project initialization
Open a docker container with all the required tooling: gradle, git.
docker run -it --rm gradle:4.10-jdk8 /bin/bash
Let's create a simple java gradle project.
mkdir demo-jgitver && \
cd demo-jgitver && \
gradle init --type java-library && \
export JL_LINE=$(grep -n "id 'java-library'" build.gradle | cut -d ':' -f 1) && \
gradle build
With some git history
echo build/ > .gitignore && \
git init && \
git config user.name "Scrap Kata-Coda" && \
git config user.email "[email protected]" && \
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" && \
git add . && \
git commit -m "initial version"
We now have a default buildable gradle project.
What is the current project version?
gradle --console=plain properties | grep -E '^version:.*'
The build.gradle
does not define the value of the version
property provided by the java-library
plugin, so it is reported as undefined
.
In standard Gradle projects, you would edit the build.gradle
file in order to set the version
property to 1.0.0
, 2.1.1-SNAPSHOT
or something like that.
We are not going to do that, and instead we'll use the power of jgitver.