Added automatic git version infomation to startup (#327)

* Added automatic git version infomation to startup

* Moved to compile time replacement

* Cleaned up old functions

* Removed redundant variable

* Added project version to version string
This commit is contained in:
rtm516 2020-05-04 20:17:25 +01:00 committed by GitHub
parent 3c7e89ba3f
commit 129e10c920
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 80 additions and 3 deletions

View File

@ -164,4 +164,83 @@
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.0</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<format>properties</format>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
<runOnlyOnce>false</runOnlyOnce>
<verbose>true</verbose>
<skipPoms>false</skipPoms>
<excludeProperties>
<excludeProperty>git.user.*</excludeProperty>
</excludeProperties>
<commitIdGenerationMode>flat</commitIdGenerationMode>
<gitDescribe>
<always>true</always>
</gitDescribe>
</configuration>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>add-version</id>
<phase>process-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<includes>
<include>${project.basedir}/src/main/java/org/geysermc/connector/GeyserConnector.java</include>
</includes>
<replacements>
<replacement>
<token>VERSION = ".*"</token>
<value>VERSION = "${project.version} (git-${git.branch}-${git.commit.id.abbrev})"</value>
</replacement>
</replacements>
</configuration>
</execution>
<execution>
<id>remove-version</id>
<phase>process-classes</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<includes>
<include>${project.basedir}/src/main/java/org/geysermc/connector/GeyserConnector.java</include>
</includes>
<replacements>
<replacement>
<token>VERSION = ".*"</token>
<value>VERSION = "DEV"</value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -28,9 +28,7 @@ package org.geysermc.connector;
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
import com.nukkitx.protocol.bedrock.BedrockServer;
import com.nukkitx.protocol.bedrock.v390.Bedrock_v390;
import lombok.Getter;
import org.geysermc.common.AuthType;
import org.geysermc.common.PlatformType;
import org.geysermc.connector.bootstrap.GeyserBootstrap;
@ -59,7 +57,7 @@ public class GeyserConnector {
public static final BedrockPacketCodec BEDROCK_PACKET_CODEC = Bedrock_v390.V390_CODEC;
public static final String NAME = "Geyser";
public static final String VERSION = "1.0-SNAPSHOT";
public static final String VERSION = "DEV"; // A fallback for running in IDEs
private final Map<InetSocketAddress, GeyserSession> players = new HashMap<>();