import java.time.LocalDateTime import java.time.format.DateTimeFormatter import java.nio.file.Path gradle.allprojects { ext.getCurrentVersion = { -> def stdout = new ByteArrayOutputStream() String tagIsh try { exec { commandLine 'git', 'describe', '--tags', '--exclude="[dD]ev*"' standardOutput = stdout } tagIsh = stdout.toString().trim().toLowerCase() } catch(Exception e) { tagIsh = "dev-Unknown" } // Dev tags: v2021.1.6-3-gf922466d // We're specifically looking to capture the middle -3- boolean isDev = tagIsh.matches(".*-[0-9]*-g[0-9a-f]*") if(isDev && !tagIsh.startsWith("dev-")) tagIsh = "dev-" + tagIsh println("Picked up version: " + tagIsh) return tagIsh } if(!ext.has("versionString")) { ext.versionString = getCurrentVersion() } }