Gradle Release Plugin Bookmarks

Published: 2017-08-27, Updated: 2023-03-14

Como deve ser o fluxo para gerar um pacote usando esse plugin

Exemplos

Especificar a versao

$ gradle release -Prelease.releaseVersion=1.0.0 -Prelease.newVersion=1.1.0-SNAPSHOT

Atualizar a versão para vários arquivos

release {
  project.ext.set("release.useAutomaticVersion", true)
  git {
    requireBranch = ''
  }
  failOnCommitNeeded = true
  failOnPublishNeeded = true
  failOnUnversionedFiles = true
  buildTasks = ['build']
}

confirmReleaseVersion.doLast {
  updateVersion("checkstyle.xml")
  updateVersion(".editorconfig")
}

def updateVersion(fileName) {
  def f = file("${rootDir}/$fileName")
  def text = f.text
  f.withWriter { w ->
    w << text.replaceAll("(version: )\\d+\\.\\d+\\.\\d+", "\$1${version}")
  }
}

Forçar o plugin a fazer bump de versão e então comitar o properties com a mesma versao


release {

  project.ext.set("release.useAutomaticVersion", true)
  def rg = ~/(\d+)([^\d]*$)/
  def m = rg.matcher(String.valueOf(project.version))
  def v = m.replaceAll("${(m[0][1] as int) + 1}${m[0][2]}")
  project.ext.set("release.releaseVersion", v)
  project.ext.set("release.newVersion", v)
  git {
    requireBranch = 'main'
  }
  failOnCommitNeeded = false
  failOnPublishNeeded = false
  failOnUnversionedFiles = false
  buildTasks = []
}

confirmReleaseVersion.doLast {
  def f = file("${project.projectDir}/README.md")
  def text = f.text
  f.withWriter { w ->
    w << text.replaceAll("(:\\ )*\\d+\\.\\d+\\.\\d+", "\$1${version}")
  }
}

Lifecycle do plugin

O lifecycle desse plugin é o seguinte:

Ou seja, o numero que foi gerado agora só será release na proxima geração de release, ex:

Desligar push para a master

release {
  git {
    pushToRemote.set('') // disabling push to remote
  }
}

Releases

Versão específica

./gradlew release -Prelease.releaseVersion=3.6.0 -Prelease.newVersion=3.6.1

gradle release commands, gradle release examples, gradle release bookmarks


Programmer Utils Saving data to two JDBC tables granting atomicity in Apache Spark

Comments