Class VersioningExtension

java.lang.Object
dev.rafandoo.versioning.VersioningExtension

public class VersioningExtension extends Object
Gradle extension that exposes the project's semantic version in a safe and readable way.

This class provides read-only access to the current Version and its components: major, minor, patch, and release candidate (RC). Modifications to the version should be performed via tasks, not directly through this extension.

  • Constructor Details

    • VersioningExtension

      public VersioningExtension(org.gradle.api.Project project)
      Constructs a VersioningExtension for the given project. The version is persisted in a version.properties file in the project root.
      Parameters:
      project - the Gradle project
  • Method Details

    • getVersion

      public Version getVersion()
      Returns the current version as a Version object.
      Returns:
      current Version (immutable)
    • getName

      public String getName()
      Returns the full version string, including release candidate if present.
      Returns:
      full semantic version string (e.g., "1.2.3-RC1" or "1.2.3")
    • getMajor

      public int getMajor()
      Returns the MAJOR component of the current version.
      Returns:
      major version number
    • getMinor

      public int getMinor()
      Returns the MINOR component of the current version.
      Returns:
      minor version number
    • getPatch

      public int getPatch()
      Returns the PATCH component of the current version.
      Returns:
      patch version number
    • getReleaseCandidate

      public int getReleaseCandidate()
      Returns the Release Candidate (RC) number of the current version. Returns 0 if this version is not a release candidate.
      Returns:
      release candidate number