vivin / gradle-semantic-build-versioning

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

Single command to Increment version in build.gradle #112

Closed Aidan-OS closed 4 years ago

Aidan-OS commented 4 years ago

I have been attempting to work with this plugin for the last two days and just cannot work my way around the documentation for it. All I want to do is be able to run a command in the command line that increments the version in my build.gradle file and then tags the Git branch. My current code is as follows.

build.gradle (Heavily simplified)

version '0.3.21'
dependancies {
    . 
    .
    . 
}

settings.gradle

rootProject.name = 'project'
buildscript {
    repositories {
        maven {
            url 'https://plugins.gradle.org/m2/'
        }
    }
    dependencies {
        classpath 'gradle.plugin.net.vivin:gradle-semantic-build-versioning:4.0.0'
    }
}

apply plugin: 'net.vivin.gradle-semantic-build-versioning'

semantic-build-versioning.gradle

startingVersion='0.3.21'

This is the setup I have currently come to rest on. I have tried running ./gradlew tag -Pbumpcomponent=patch -Prelease in command line and the first time it worked, tagging the branch but not changing any versioning in the files. I then tried made a change to my Pipeline config to create a second commit to test, and I am met with this error:

* What went wrong:
Execution failed for task ':tag'.
> org.eclipse.jgit.api.errors.RefAlreadyExistsException: tag 'Tag={
  object badde91bcac1bc30bcecc51b872b047318da54fb
  type commit
  tag 0.3.21
  tagger PersonIdent[Aidan Smith, aidan@companyname.com, Tue Mar 31 11:17:39 2020 -0400]

  }' already exists

*

Is there any assistance you can offer? My goal is to be able to commit a patch version bump automatically through CI that changes the version in build.gradle and tags the git branch.

Aidan-OS commented 4 years ago

After review with some co-workers, we were able to determine that the "version" object is no longer needed in build.gradle as this plugin provides the version when needed, which was not clear. Removing the version number from build.gradle solved the issue.

vivin commented 4 years ago

@Aidan-OS I'm so sorry for the late response.

I will try to take a look at your comment (though it looks you got it fixed). I'm trying to get a new release out but have run into weird issues related to Gradle version changes (tests are failing).

But I'm also working full-time and going to school full-time, so I am not able to spend as much time on this as I want to.