Difficulty: Beginner
Estimated Time: 10 minutes

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:

jgitver gradle simple usage

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:

jgitver on Gradle, an introduction using docker

Step 1 of 3

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.

Creating Katacoda Scenarios

Thanks for creating Katacoda scenarios. This tab is designed to help you as an author have quick access the information you need when creating scenarios.

This tab will not be visible to users.

Here are some useful links to get you started.

Running Katacoda Workshops

If you are planning to use Katacoda for workshops, please contact [email protected] to arrange capacity.

Debugging Scenarios

Below is the response from any background scripts run or files uploaded. This stream can aid debugging scenarios.

If you still need assistance, please contact [email protected]