// -*- java -*-
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id "java"
id "distribution"
// needs to use old plugin mechanism otherwise I can't set the extra properties
// https://github.com/Nasdaq/semver-git
// execute showVersion task to see what the version will be
id "com.cinnober.gradle.semver-git" version "2.3.1" apply false
}
//foo
// needs to use old plugin mechanism otherwise I can't set nextVersion and snapshotSuffix
//ext.nextVersion = "patch" // "major", "minor" (default), "patch" or e.g. "3.0.0-rc2"
ext.dirtyMarker = "-dirty" // (default) replaces <dirty> in snapshotSuffix
ext.snapshotSuffix = "beta.<count>+g<sha><dirty>" // "SNAPSHOT" (default) or a pattern, e.g. "<count>.g<sha><dirty>-SNAPSHOT"
// optionally: ext.gitDescribeArgs = '--match *[0-9].[0-9]*.[0-9]*' (default) or other arguments for git describe.
// must be after the ext.* variables are set
apply plugin: "com.cinnober.gradle.semver-git"
repositories {
mavenCentral()
}
group = "test"
>git --no-pager status
On branch main
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: build.gradle
no changes added to commit (use "git add" and/or "git commit -a")
>./gradlew showVersion
> Task :showVersion
Version: 0.1.0-beta.1+g4d4a7d7<dirty>
BUILD SUCCESSFUL in 413ms
1 actionable task: 1 executed
>git --no-pager status
On branch main
nothing to commit, working tree clean
>./gradlew showVersion
> Task :showVersion
Version: 0.1.0-beta.2+g6fd2f4b<dirty>
BUILD SUCCESSFUL in 445ms
1 actionable task: 1 executed
I expected the first execution to replace "" with "-dirty".
The second execution should not have "" in it at all.
Using gradle 7.5.1 and git 2.34.1 on Linux
Build file:
I expected the first execution to replace "" with "-dirty".
The second execution should not have "" in it at all.