From 0bb8d8b2d98f70c712403937f3618f5bbe5bdd1d Mon Sep 17 00:00:00 2001 From: soloturn Date: Sat, 14 Oct 2023 14:10:46 +0200 Subject: [PATCH] permit to override the jgitver version for packaging a tar ball, jgitver takes the default version of 0.0.0, not practical. putting a version into a file would be possible, but we try to produce a new version with every commit, which then can be released if tests pass, without rebuild. this means the source code should NOT have the version in the commit, but derived. for tar balls, we know the name of the tar, so its easy to set the same version in a script, or put a desired version. pay attention, that ripme checks the version towards github, and suggests an update, if the running version is less than the released one. fixes #145. --- build.gradle.kts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index e57b8579..a5c77e48 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,9 @@ -// permits to start the build setting the javac release parameter, no parameter means build for java8: -// gradle clean build -PjavacRelease=8 -// gradle clean build -PjavacRelease=17 +// the build derives a version with the jgitver plugin out of a tag in the git history. when there is no +// git repo, the jgitver default would be 0.0.0. one can override this version with a parameter. also, permit +// to start the build setting the javac release parameter, no parameter means build for java-17: +// gradle clean build -PjavacRelease=21 +// gradle clean build -PcustomVersion=1.0.0-10-asdf +val customVersion = (project.findProperty("customVersion") ?: "") as String val javacRelease = (project.findProperty("javacRelease") ?: "17") as String plugins { @@ -48,6 +51,12 @@ jgitver { useGitCommitID = true } +afterEvaluate { + if (customVersion != "") { + project.version = customVersion + } +} + tasks.compileJava { options.release.set(Integer.parseInt(javacRelease)) }