Groovy & Gradle: JVM Automation and Build Engineering · Lektion

Versionierung und Release-Automatisierung

Automatisieren Sie semantische Versionierung, Git-Tagging und Release-Abläufe in Gradle, sodass jeder Build reproduzierbar identifiziert ist und Releases nur einen Befehl entfernt sind.

Lektion 4 von 413 Schritte

Versionierung und Release-Automatisierung ist eine kostenlose Groovy & Gradle: JVM Automation and Build Engineering-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Groovy & Gradle: JVM Automation and Build Engineering-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Groovy & Gradle: JVM Automation and Build Engineering-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

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
Kostenlos starten

Lerne Groovy mit einem KI-Tutor — kostenlos

Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.

Kurse
12
Lektionen
48

Häufig gestellte Fragen

Ist die Lektion „Versionierung und Release-Automatisierung“ kostenlos?

Ja — der vollständige Text von „Versionierung und Release-Automatisierung“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Groovy & Gradle: JVM Automation and Build Engineering-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Groovy & Gradle: JVM Automation and Build Engineering-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Versionierung und Release-Automatisierung“?

Automatisieren Sie semantische Versionierung, Git-Tagging und Release-Abläufe in Gradle, sodass jeder Build reproduzierbar identifiziert ist und Releases nur einen Befehl entfernt sind. Du übst Groovy & Gradle: JVM Automation and Build Engineering mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Groovy & Gradle: JVM Automation and Build Engineering zu starten?

Keine Vorkenntnisse erforderlich. Groovy & Gradle: JVM Automation and Build Engineering auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Versionierung und Release-Automatisierung“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Groovy & Gradle: JVM Automation and Build Engineering-Lektion Code schreiben und ausführen?

Ja. Jede Groovy & Gradle: JVM Automation and Build Engineering-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. JARs, WARs und EARs paketieren
  2. In Repositories veröffentlichen
  3. CI/CD-Integration
  4. Versionierung und Release-Automatisierung
← Zurück zu Groovy & Gradle: JVM Automation and Build Engineering