Module

gitlab

A dependency-free Java library that reads tag and version information from the GitLab REST API through a single source-of-truth class, GitLabPlatform. Every call is asynchronous and returns a CompletableFuture.

Java 21 v0.0.0 No dependencies

Coordinates

groupId
io.github.mcengine
artifactId
gitlab
version
0.0.0
namespace
io.github.mcengine.gitlab
class
io.github.mcengine.gitlab.common.GitLabPlatform

Add the dependency

The library is published to its own GitHub Packages registry. Authenticate with a token that has the read:packages scope, then declare the dependency (Gradle, Groovy DSL):

build.gradle
repositories {
    maven {
        url = uri("https://maven.pkg.github.com/MCEngine/gitlab")
        credentials {
            username = System.getenv("GITHUB_ACTOR")
            password = System.getenv("GITHUB_TOKEN")
        }
    }
}

dependencies {
    implementation "io.github.mcengine:gitlab:0.0.0"
}

GITHUB_ACTOR and GITHUB_TOKEN authenticate against GitHub Packages, where the artifact is hosted. At runtime the library talks to the GitLab API; supply a GitLab token in code only for private projects.

Usage

Construct the platform with an owner and project, then call any of the three methods. Results arrive through a CompletableFuture:

Example
GitLabPlatform platform = new GitLabPlatform("MCEngine", "gitlab");

// Latest tag (or null when the project has no tags)
platform.getLatestTag().thenAccept(tag -> {
    System.out.println(tag == null ? "no tags yet" : tag.getName());
});

// A specific tag by name (or null when it does not exist)
platform.getTag("v0.0.0").thenAccept(tag -> { /* ... */ });

// Is the latest tag newer than a plain version? (the "v" prefix is handled)
boolean newer = platform.CompareVersion("0.0.0").join();

// For a private project, pass a GitLab token (sent as the PRIVATE-TOKEN header):
GitLabPlatform authed = new GitLabPlatform("MCEngine", "gitlab", gitlabToken);

Pass the version to CompareVersion without a prefix (for example 1.0.0). Tags stored as v1.0.0 have the v removed before the Major.Minor.Patch comparison.

Method reference

Import only GitLabPlatform. It returns tags as the read-only GitLabTag interface.

CompletableFuture<GitLabTag> getLatestTag()

Resolves to the latest tag by semantic version, or null when the project has no tags.

CompletableFuture<GitLabTag> getTag(String tagName)

Resolves to the tag whose name equals tagName, or null when it does not exist.

CompletableFuture<Boolean> CompareVersion(String version)

Resolves to true when the latest tag is a newer semantic version than version; false when it is not newer or when the project has no tags.

GitLabTag

MethodReturnsDescription
getName()StringTag name as stored on GitLab, for example v0.0.0.
getCommitSha()StringCommit SHA the tag points at, or null when unknown.

FAQ

Does it pull in any third-party libraries?

No. The module uses only the Java Platform — the built-in HTTP client and CompletableFuture — so it adds no transitive dependencies.

How is the GitLab project addressed?

By its URL-encoded owner/project path, so you pass the owner and project name and the library builds the request for you.

Does it cache results?

No. The class holds only the connection details you pass in; every call fetches fresh data and returns it.