Package dev.rafandoo.versioning
Class VersioningExtension
java.lang.Object
dev.rafandoo.versioning.VersioningExtension
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 Summary
ConstructorsConstructorDescriptionVersioningExtension(org.gradle.api.Project project) Constructs a VersioningExtension for the given project. -
Method Summary
Modifier and TypeMethodDescriptionintgetMajor()Returns the MAJOR component of the current version.intgetMinor()Returns the MINOR component of the current version.getName()Returns the full version string, including release candidate if present.intgetPatch()Returns the PATCH component of the current version.intReturns the Release Candidate (RC) number of the current version.Returns the current version as aVersionobject.
-
Constructor Details
-
VersioningExtension
public VersioningExtension(org.gradle.api.Project project) Constructs a VersioningExtension for the given project. The version is persisted in aversion.propertiesfile in the project root.- Parameters:
project- the Gradle project
-
-
Method Details
-
getVersion
Returns the current version as aVersionobject.- Returns:
- current Version (immutable)
-
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
-