Add git information to EngineInformation

This commit is contained in:
JeremyStar™ 2024-06-28 18:21:59 +02:00
parent 51f0405895
commit 116bc4b0b9
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
20 changed files with 988 additions and 26 deletions

1
base/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
src/main/resources/git.properties

View file

@ -20,6 +20,7 @@
plugins {
id 'java'
id 'io.freefair.lombok' version "${pluginLombok}"
id "com.gorylenko.gradle-git-properties" version "${pluginGitProperties}"
id 'maven-publish'
}
@ -51,6 +52,29 @@ dependencies {
testImplementation 'org.jooq:joor:' + project.dependencyJoor
}
gitProperties {
dotGitDirectory = file("${rootProject.rootDir}/.git")
failOnNoGitDirectory = false
extProperty = 'gitProps'
dateFormat = "yyyy-MM-dd'T'HH:mmZ"
dateFormatTimeZone = "UTC"
}
tasks.register("writeGitProperties") {
doLast {
File target = file("${project.projectDir}/src/main/resources/git.properties")
File source = file("${project.projectDir}/build/resources/main/git.properties")
target.delete()
source.renameTo(target)
}
outputs.upToDateWhen { false }
}
generateGitProperties.outputs.upToDateWhen { false }
processResources.dependsOn 'writeGitProperties'
javadoc.options {
setMemberLevel(JavadocMemberLevel.PUBLIC)
setOverview("src/main/javadoc/overview.html")

View file

@ -21,6 +21,7 @@ package de.staropensource.sosengine.base;
import de.staropensource.sosengine.base.classes.SubsystemMainClass;
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
import de.staropensource.sosengine.base.classes.logging.LogIssuer;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import de.staropensource.sosengine.base.events.EngineCrashEvent;
import de.staropensource.sosengine.base.events.EngineShutdownEvent;
@ -30,8 +31,9 @@ import de.staropensource.sosengine.base.logging.CrashHandler;
import de.staropensource.sosengine.base.logging.Logger;
import de.staropensource.sosengine.base.logging.LoggerInstance;
import de.staropensource.sosengine.base.types.CodePart;
import de.staropensource.sosengine.base.classes.logging.LogIssuer;
import de.staropensource.sosengine.base.utility.*;
import de.staropensource.sosengine.base.utility.Miscellaneous;
import de.staropensource.sosengine.base.utility.PlaceholderEngine;
import de.staropensource.sosengine.base.utility.ShortcodeConverter;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Range;
@ -123,7 +125,7 @@ public final class Engine implements SubsystemMainClass {
logger = new LoggerInstance(new LogIssuer(getClass(), CodePart.ENGINE));
});
logger.info("Initialized sos!engine v%engine_version% in " + initTime + "ms");
logger.info("Initialized sos!engine v%engine_version% (commit %engine_git_commit_id_long%-%engine_git_branch%, dirty %engine_git_dirty%) in " + initTime + "ms");
}
/**

View file

@ -19,15 +19,22 @@
package de.staropensource.sosengine.base.data.info;
import de.staropensource.sosengine.base.Engine;
import de.staropensource.sosengine.base.classes.logging.LogIssuer;
import de.staropensource.sosengine.base.logging.Logger;
import de.staropensource.sosengine.base.logging.LoggerInstance;
import de.staropensource.sosengine.base.types.CodePart;
import de.staropensource.sosengine.base.classes.logging.LogIssuer;
import de.staropensource.sosengine.base.types.VersionType;
import de.staropensource.sosengine.base.utility.PropertyParser;
import lombok.Getter;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.ZonedDateTime;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Properties;
/**
@ -105,6 +112,124 @@ public final class EngineInformation {
private String versioningFork;
/**
* Provides the {@code dirty} value (i.e. if the source tree has been modified).
*
* @since 1-alpha1
*
* -- GETTER --
* Provides the {@code dirty} value (i.e. if the source tree has been modified).
*
* @return git dirty value
* @since 1-alpha1
*/
private Boolean gitDirty;
/**
* Provides the branch the engine was built on.
*
* @since 1-alpha1
*
* -- GETTER --
* Provides the branch the engine was built on.
*
* @return git branch
* @since 1-alpha1
*/
private String gitBranch;
/**
* Provides the commit count.
*
* @since 1-alpha1
*
* -- GETTER --
* Provides the commit count.
*
* @return git commit count
* @since 1-alpha1
*/
private int gitCommitCount;
/**
* Provides the commit identifier (short form).
*
* @since 1-alpha1
*
* -- GETTER --
* Provides the commit identifier (short form).
*
* @return git long commit id
* @since 1-alpha1
*/
private String gitCommitIdentifierShort;
/**
* Provides the commit identifier (long form).
*
* @since 1-alpha1
*
* -- GETTER --
* Provides the commit identifier (long form).
*
* @return git long commit id
* @since 1-alpha1
*/
private String gitCommitIdentifierLong;
/**
* Provides the commit header.
*
* @since 1-alpha1
*
* -- GETTER --
* Provides the commit header.
*
* @return git commit header
* @since 1-alpha1
*/
private String gitCommitHeader;
/**
* Provides the commit time.
*
* @since 1-alpha1
*
* -- GETTER --
* Provides the commit time.
*
* @return git commit time
* @since 1-alpha1
*/
private ZonedDateTime gitCommitTime;
/**
* Provides the commiter's name.
*
* @since 1-alpha1
*
* -- GETTER --
* Provides the commiter's name.
*
* @return git committer name
* @since 1-alpha1
*/
private String gitCommitterName;
/**
* Provides the commiter's email.
*
* @since 1-alpha1
*
* -- GETTER --
* Provides the commiter's email.
*
* @return git committer email
* @since 1-alpha1
*/
private String gitCommitterEmail;
/**
* Provides the version of the dependency {@code Lombok}.
*
@ -215,19 +340,25 @@ public final class EngineInformation {
* @since 1-alpha0
*/
public EngineInformation() {
LoggerInstance logger = new LoggerInstance(new LogIssuer(getClass(), CodePart.ENGINE));
// Only allow one instance
if (instance == null)
instance = this;
else {
logger.crash("Tried reinitializing " + getClass().getName() + " twice");
return;
Logger.crash(new LogIssuer(getClass(), CodePart.ENGINE), "Tried reinitializing " + getClass().getName() + " twice");
}
}
/**
* Updates all variables.
*
* @since 1-alpha1
*/
public void load() {
LoggerInstance logger = new LoggerInstance(new LogIssuer(getClass(), CodePart.ENGINE));
// Load properties from bundled gradle.properties
Properties properties = new Properties();
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("gradle.properties");
Properties gradleProperties = new Properties();
InputStream gradleStream = this.getClass().getClassLoader().getResourceAsStream("gradle.properties");
if (inputStream == null) {
logger.crash("Unable to load build information: The bundled gradle.properties file could not be found. Do symlinks work on the system that built this JAR?");
@ -235,30 +366,76 @@ public final class EngineInformation {
}
try {
properties.load(inputStream);
inputStream.close();
gradleProperties.load(gradleStream);
gradleStream.close();
} catch (IOException exception) {
logger.crash("Unable to load build information: InputStream failed", exception);
return;
}
// Create new PropertyParser
PropertyParser parser = new PropertyParser(properties);
// Load properties from bundled git.properties
// or fill in blank information if file missing
Properties gitProperties = new Properties();
InputStream gitStream = this.getClass().getClassLoader().getResourceAsStream("git.properties");
if (gitStream == null) {
logger.error("Unable to load build information: The bundled git.properties file could not be found. Did you download a tarball?");
// Fake information
gitProperties.setProperty("git.total.commit.count", "0");
gitProperties.setProperty("git.dirty", "true");
gitProperties.setProperty("git.branch", "/unknown/");
gitProperties.setProperty("git.commit.id", "########################################");
gitProperties.setProperty("git.commit.id.abbrev", "#######");
gitProperties.setProperty("git.commit.message.short", "git.properties file is missing :/");
gitProperties.setProperty("git.commit.time", "1970-01-01T00:00:00+0000");
gitProperties.setProperty("git.commit.user.name", "git.properties file is missing :/");
gitProperties.setProperty("git.commit.user.email", "git.properties-is-missing@example.com");
} else {
// Load real information from git.properties file
try {
gitProperties.load(gitStream);
gitStream.close();
} catch (IOException exception) {
logger.crash("Unable to load build information: InputStream 'gitStream' failed", exception);
return;
}
}
// Create new PropertyParsers
PropertyParser gradleParser = new PropertyParser(gradleProperties);
PropertyParser gitParser = new PropertyParser(gitProperties);
// Apply properties to fields
versioningVersion = parser.getInteger("versioningVersion", true);
versioningType = VersionType.valueOf(parser.getString("versioningType").toUpperCase());
versioningTyperelease = parser.getInteger("versioningTyperelease", true);
versioningFork = parser.getString("versioningFork");
versioningVersion = gradleParser.getInteger("versioningVersion", true);
versioningType = VersionType.valueOf(gradleParser.getString("versioningType").toUpperCase());
versioningTyperelease = gradleParser.getInteger("versioningTyperelease", true);
versioningFork = gradleParser.getString("versioningFork");
dependencyLombok = parser.getString("dependencyLombok");
dependencyJetbrainsAnnotations = parser.getString("dependencyJetbrainsAnnotations");
dependencyJansi = parser.getString("dependencyJansi");
dependencyReflections = parser.getString("dependencyReflections");
dependencySlf4j = parser.getString("dependencySlf4j");
dependencyLwjgl = parser.getString("dependencyLwjgl");
dependencyLombok = gradleParser.getString("dependencyLombok");
dependencyJetbrainsAnnotations = gradleParser.getString("dependencyJetbrainsAnnotations");
dependencyJansi = gradleParser.getString("dependencyJansi");
dependencyReflections = gradleParser.getString("dependencyReflections");
dependencySlf4j = gradleParser.getString("dependencySlf4j");
dependencyLwjgl = gradleParser.getString("dependencyLwjgl");
pluginShadow = parser.getString("pluginShadow");
pluginLombok = parser.getString("pluginLombok");
gitDirty = gitParser.getBoolean("git.dirty");
gitBranch = gitParser.getString("git.branch");
gitCommitCount = gitParser.getInteger("git.total.commit.count", true);
gitCommitIdentifierShort = gitParser.getString("git.commit.id.abbrev");
gitCommitIdentifierLong = gitParser.getString("git.commit.id");
gitCommitHeader = gitParser.getString("git.commit.message.short");
try {
Date date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmZ").parse(gitParser.getString("git.commit.time"));
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
gitCommitTime = calendar.toZonedDateTime();
} catch (ParseException e) {
logger.crash("Unable to load build information: Can't parse \"" + gitParser.getString("git.commit.time") + "\" using format \"yyyy-MM-dd'T'HH:mmZ\"");
}
gitCommitterName = gitParser.getString("git.commit.user.name");
gitCommitterEmail = gitParser.getString("git.commit.user.email");
pluginShadow = gradleParser.getString("pluginShadow");
pluginLombok = gradleParser.getString("pluginLombok");
}
}

View file

@ -0,0 +1,53 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_branch} placeholder.
*
* @see Placeholder
* @since 1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitBranch implements Placeholder {
/**
* Constructor.
*
* @since 1-alpha0
*/
public EngineGitBranch() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_git_branch";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", EngineInformation.getInstance().getGitBranch());
}
}

View file

@ -0,0 +1,53 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_header} placeholder.
*
* @see Placeholder
* @since 1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitHeader implements Placeholder {
/**
* Constructor.
*
* @since 1-alpha0
*/
public EngineGitCommitHeader() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_git_commit_header";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", EngineInformation.getInstance().getGitCommitHeader());
}
}

View file

@ -0,0 +1,53 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_id_long} placeholder.
*
* @see Placeholder
* @since 1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitIdLong implements Placeholder {
/**
* Constructor.
*
* @since 1-alpha0
*/
public EngineGitCommitIdLong() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_git_commit_id_long";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", EngineInformation.getInstance().getGitCommitIdentifierLong());
}
}

View file

@ -0,0 +1,53 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_id_short} placeholder.
*
* @see Placeholder
* @since 1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitIdShort implements Placeholder {
/**
* Constructor.
*
* @since 1-alpha0
*/
public EngineGitCommitIdShort() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_git_commit_id_short";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", EngineInformation.getInstance().getGitCommitIdentifierShort());
}
}

View file

@ -0,0 +1,53 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_time_day} placeholder.
*
* @see Placeholder
* @since 1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitTimeDay implements Placeholder {
/**
* Constructor.
*
* @since 1-alpha0
*/
public EngineGitCommitTimeDay() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_git_commit_time_day";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getInstance().getGitCommitTime().getDayOfMonth()));
}
}

View file

@ -0,0 +1,53 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_time_hour} placeholder.
*
* @see Placeholder
* @since 1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitTimeHour implements Placeholder {
/**
* Constructor.
*
* @since 1-alpha0
*/
public EngineGitCommitTimeHour() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_git_commit_time_hour";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getInstance().getGitCommitTime().getHour()));
}
}

View file

@ -0,0 +1,53 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_time_minute} placeholder.
*
* @see Placeholder
* @since 1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitTimeMinute implements Placeholder {
/**
* Constructor.
*
* @since 1-alpha0
*/
public EngineGitCommitTimeMinute() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_git_commit_time_minute";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getInstance().getGitCommitTime().getMinute()));
}
}

View file

@ -0,0 +1,53 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_time_month} placeholder.
*
* @see Placeholder
* @since 1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitTimeMonth implements Placeholder {
/**
* Constructor.
*
* @since 1-alpha0
*/
public EngineGitCommitTimeMonth() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_git_commit_time_month";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getInstance().getGitCommitTime().getMonth()));
}
}

View file

@ -0,0 +1,53 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_time_second} placeholder.
*
* @see Placeholder
* @since 1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitTimeSecond implements Placeholder {
/**
* Constructor.
*
* @since 1-alpha0
*/
public EngineGitCommitTimeSecond() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_git_commit_time_second";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getInstance().getGitCommitTime().getSecond()));
}
}

View file

@ -0,0 +1,53 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commit_time_year} placeholder.
*
* @see Placeholder
* @since 1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitTimeYear implements Placeholder {
/**
* Constructor.
*
* @since 1-alpha0
*/
public EngineGitCommitTimeYear() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_git_commit_time_year";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getInstance().getGitCommitTime().getYear()));
}
}

View file

@ -0,0 +1,53 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_commits} placeholder.
*
* @see Placeholder
* @since 1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommits implements Placeholder {
/**
* Constructor.
*
* @since 1-alpha0
*/
public EngineGitCommits() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_git_commits";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getInstance().getGitCommitCount()));
}
}

View file

@ -0,0 +1,53 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_committer_email} placeholder.
*
* @see Placeholder
* @since 1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitterEmail implements Placeholder {
/**
* Constructor.
*
* @since 1-alpha0
*/
public EngineGitCommitterEmail() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_git_committer_email";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", EngineInformation.getInstance().getGitCommitterEmail());
}
}

View file

@ -0,0 +1,53 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_committer_name} placeholder.
*
* @see Placeholder
* @since 1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitCommitterName implements Placeholder {
/**
* Constructor.
*
* @since 1-alpha0
*/
public EngineGitCommitterName() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_git_committer_name";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", EngineInformation.getInstance().getGitCommitterName());
}
}

View file

@ -0,0 +1,53 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.base.data.placeholders;
import de.staropensource.sosengine.base.classes.Placeholder;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import org.jetbrains.annotations.NotNull;
/**
* Implements the {@code engine_git_dirty} placeholder.
*
* @see Placeholder
* @since 1-alpha0
*/
@SuppressWarnings({ "unused" })
public final class EngineGitDirty implements Placeholder {
/**
* Constructor.
*
* @since 1-alpha0
*/
public EngineGitDirty() {}
/** {@inheritDoc} */
@NotNull
public String getName() {
return "engine_git_dirty";
}
/** {@inheritDoc} */
@NotNull
@Override
public String replace(@NotNull String text) {
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getInstance().getGitDirty()));
}
}

View file

@ -94,6 +94,21 @@ public final class PlaceholderEngine {
placeholders.add(new EngineDependencyLwjgl());
placeholders.add(new EngineDependencyReflections());
placeholders.add(new EngineDependencySlf4j());
// engine_git_*
placeholders.add(new EngineGitBranch());
placeholders.add(new EngineGitCommitHeader());
placeholders.add(new EngineGitCommitIdLong());
placeholders.add(new EngineGitCommitIdShort());
placeholders.add(new EngineGitCommits());
placeholders.add(new EngineGitCommitterEmail());
placeholders.add(new EngineGitCommitterName());
placeholders.add(new EngineGitCommitTimeDay());
placeholders.add(new EngineGitCommitTimeHour());
placeholders.add(new EngineGitCommitTimeMinute());
placeholders.add(new EngineGitCommitTimeMonth());
placeholders.add(new EngineGitCommitTimeSecond());
placeholders.add(new EngineGitCommitTimeYear());
placeholders.add(new EngineGitDirty());
// engine_plugin_*
placeholders.add(new EnginePluginLombok());
placeholders.add(new EnginePluginShadow());

View file

@ -41,6 +41,7 @@ dependencyJoor=0.9.14
# Plugins
pluginShadow=8.1.1
pluginLombok=8.6
pluginGitProperties=2.4.2
# etc
group = de.staropensource.sosengine