Groovy & Gradle: JVM Automation and Build Engineering · Aula

Versionamento e Automatização de Versões

Automatize o versionamento semântico, as etiquetas Git e os fluxos de lançamento no Gradle, para que cada compilação seja identificada de forma reproduzível e as versões fiquem a um comando de distância.

Aula 4 de 413 etapas

Versionamento e Automatização de Versões é uma aula grátis de Groovy & Gradle: JVM Automation and Build Engineering no CoddyKit. Esta é a aula 4 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Groovy & Gradle: JVM Automation and Build Engineering, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Groovy & Gradle: JVM Automation and Build Engineering inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Why Versioning Matters

A clear version on every artifact tells consumers what changed and lets you roll back safely. Manual edits to a version string are error prone, so we automate them.

Setting the Project Version

Every Gradle project has a version property used to name published artifacts.

version = "1.4.0"
group = "com.acme"

Semantic Versioning

SemVer uses MAJOR.MINOR.PATCH:

  • MAJOR: breaking changes
  • MINOR: new backward-compatible features
  • PATCH: backward-compatible fixes

SNAPSHOT vs Release

A -SNAPSHOT suffix marks an in-development build that may change. Releases drop the suffix and are immutable once published.

version = "1.5.0-SNAPSHOT"

Deriving Version from Git

Many teams compute the version from the latest Git tag so the source of truth is the repository history, not a hard-coded string.

version = providers.exec {
    commandLine("git", "describe", "--tags")
}.standardOutput.asText.get().trim()

A Release Task

Wrap the steps of a release into a single task that depends on build, tag, and publish.

tasks.register("release") {
    dependsOn("build", "publish")
}

Tagging in Git

An annotated tag records the released version in history.

git tag -a v1.5.0 -m "Release 1.5.0"
git push origin v1.5.0

Bumping the Version

After a release, bump to the next SNAPSHOT so further commits are clearly pre-release. Plugins like Axion or the release plugin automate this.

Reproducible Builds

Pin dependency versions and avoid dynamic ranges so the same source always produces the same artifact, an essential property for trustworthy releases.

implementation("com.google.guava:guava:33.0.0-jre")

Wiring into CI

In CI, run the release task only on tagged commits or a protected branch, so accidental pushes never publish.

if [ "$CI_COMMIT_TAG" ]; then gradle release; fi

Best Practices

Keep releases predictable:

  • One source of truth for the version
  • Never republish an existing release version
  • Automate tagging and the version bump

Quick Check

Test your understanding of release versioning.

Recap

You learned release automation:

  • Use SemVer for MAJOR.MINOR.PATCH
  • SNAPSHOT for dev, plain version for releases
  • Derive version from Git tags
  • Wrap build+tag+publish into a release task gated in CI
Grátis para começar

Aprenda Groovy com um tutor de IA — grátis

Escreva e execute código real no seu navegador, obtenha ajuda instantânea de um tutor de IA 24/7 e continue de onde parou na web ou no app.

Cursos
12
Aulas
48

Perguntas Frequentes

A aula “Versionamento e Automatização de Versões” é grátis?

Sim — o texto completo de “Versionamento e Automatização de Versões” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Groovy & Gradle: JVM Automation and Build Engineering, atualize para CoddyKit PRO. O curso de Groovy & Gradle: JVM Automation and Build Engineering inclui 4 aulas no total.

O que vou aprender em “Versionamento e Automatização de Versões”?

Automatize o versionamento semântico, as etiquetas Git e os fluxos de lançamento no Gradle, para que cada compilação seja identificada de forma reproduzível e as versões fiquem a um comando de distân… Você pratica Groovy & Gradle: JVM Automation and Build Engineering com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Groovy & Gradle: JVM Automation and Build Engineering?

Nenhuma experiência prévia é necessária. Groovy & Gradle: JVM Automation and Build Engineering no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 4 de 4.

Quanto tempo leva a aula “Versionamento e Automatização de Versões”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Groovy & Gradle: JVM Automation and Build Engineering?

Sim. Cada aula de Groovy & Gradle: JVM Automation and Build Engineering inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Empacotando JARs, WARs e EARs
  2. Publicando em repositórios
  3. Integração com CI/CD
  4. Versionamento e Automatização de Versões
← Voltar para Groovy & Gradle: JVM Automation and Build Engineering