vivin / gradle-semantic-build-versioning

Gradle plugin to generate version-numbers and tags using semantic versioning
MIT License
86 stars 32 forks source link

build exception - Cannot invoke method split() on null object #120

Open josephh opened 2 years ago

josephh commented 2 years ago

Running,

------------------------------------------------------------
Gradle 7.4.2
------------------------------------------------------------

Build time:   2022-03-31 15:25:29 UTC
Revision:     540473b8118064efcc264694cbcaa4b677f61041

Kotlin:       1.5.31
Groovy:       3.0.9
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          18.0.1.1 (Homebrew 18.0.1.1+0)
OS:           Mac OS X 12.5 aarch64

in settings.gradle I have,

...
buildscript {
    repositories {
        ...
    }

    dependencies {
        classpath 'io.alcide:gradle-semantic-build-versioning:4.2.2'
    }
}

apply plugin: "io.alcide.gradle-semantic-build-versioning"
...

and in my code repo i have a tag,

git tag
0.1.0

but when i run

./gradlew build

I get a build failure,

./gradlew  build --stacktrace  

FAILURE: Build failed with an exception.

* What went wrong:
Cannot invoke method split() on null object

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
java.lang.NullPointerException: Cannot invoke method split() on null object
        at net.vivin.gradle.versioning.VersionUtils.incrementVersion(VersionUtils.groovy:227)
KennethSlade commented 2 years ago

Had the same issue yesterday but managed to fix it by pruning local tags that didn't exist on remote: git fetch origin --prune --prune-tags

josephh commented 2 years ago

Saw this issue again today - on a different repo but couldn't remember how i fixed it previously 😭

  • Exception is: java.lang.NullPointerException: Cannot invoke method split() on null object at net.vivin.gradle.versioning.VersionUtils.incrementVersion(VersionUtils.groovy:227)

As a reminder of the problem (in our case at least) and how to remedy bodge it,

  1. i've cloned a repo that uses the plugin.
  2. on the main branch; git reports one existing tag.
    % git tag
    0.1.0
  3. via settings.gradle we include the plugin.
  4. in semantic-build-versioning.gradle there is the autobump property and instructions; there is also an entry startingVersion = '0.1.0'.
  5. At this point the build is failing ... but add a new local tag to the repo, git tag -a 0.1.1 and then it builds ok... 😕
  6. I don't really want the tag 0.1.1 but if i remove it, the problem recurs 😒