chore(BuildConfig): Add BuildConfig
This commit is contained in:
+43
-15
@@ -1,14 +1,45 @@
|
||||
import java.nio.file.Paths
|
||||
|
||||
plugins {
|
||||
id 'fabric-loom' version "$loom_version"
|
||||
id 'maven-publish'
|
||||
id 'com.github.gmazzo.buildconfig' version "$buildconfig_version"
|
||||
}
|
||||
|
||||
version = project.minecraft_version
|
||||
var USING_GIT = Paths.get(System.getProperty("user.dir")).resolve(".git").toFile().exists()
|
||||
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
buildConfig {
|
||||
buildConfigField(String, "NAME", project.mod_name)
|
||||
buildConfigField(String, "GROUP", project.group)
|
||||
buildConfigField(String, "VERSION", project.mod_version)
|
||||
buildConfigField(String, "BUILD_TIME", "${new Date(System.currentTimeMillis()).format("MM/dd/yyyy HH:mm")}")
|
||||
buildConfigField(Boolean, "USING_GIT", USING_GIT)
|
||||
|
||||
if (USING_GIT) {
|
||||
println "This build uses git, adding properties to build config"
|
||||
|
||||
buildConfigField(String, "HASH", "${execute("git rev-parse --short HEAD")}")
|
||||
buildConfigField(String, "BRANCH", "${execute("git branch --show-current")}")
|
||||
}
|
||||
|
||||
packageName "${project.group}.util"
|
||||
useJavaOutput()
|
||||
generateAtSync = true
|
||||
}
|
||||
|
||||
sourceSets.main.java.srcDirs += "build/gen/buildconfig/src/main"
|
||||
|
||||
base {
|
||||
archivesName = project.archives_base_name
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url "https://jitpack.io" }
|
||||
maven {
|
||||
url "https://jitpack.io"
|
||||
}
|
||||
}
|
||||
|
||||
loom {
|
||||
@@ -58,24 +89,21 @@ java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
base {
|
||||
archivesName = project.archives_base_name
|
||||
}
|
||||
|
||||
jar {
|
||||
from("LICENSE") {
|
||||
rename { "${it}_${project.archives_base_name}" }
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
dependsOn(generateBuildConfig)
|
||||
}
|
||||
|
||||
repositories {
|
||||
// Add publish targets here if needed
|
||||
def execute(String cmd) {
|
||||
var output = providers.exec {
|
||||
commandLine cmd.split(" ")
|
||||
ignoreExitValue = true
|
||||
}
|
||||
return output.standardOutput.getAsText().getOrElse("none")
|
||||
.replaceAll("\n", "");
|
||||
}
|
||||
+5
-2
@@ -7,9 +7,12 @@ yarn_mappings=1.21.11+build.4
|
||||
loader_version=0.18.4
|
||||
loom_version=1.14-SNAPSHOT
|
||||
# Mod Properties
|
||||
maven_group=me.alpha432
|
||||
maven_group=me.alpha432.oyvey
|
||||
mod_version=1.0.0
|
||||
mod_name=OyVey
|
||||
archives_base_name=oyvey
|
||||
# Dependencies
|
||||
# check this on https://modmuss50.me/fabric.html
|
||||
fabric_version=0.141.1+1.21.11
|
||||
catformat_version=2.1.0
|
||||
catformat_version=2.1.0
|
||||
buildconfig_version=5.3.5
|
||||
@@ -2,16 +2,14 @@ package me.alpha432.oyvey;
|
||||
|
||||
import me.alpha432.oyvey.features.gui.HudEditorScreen;
|
||||
import me.alpha432.oyvey.manager.*;
|
||||
import me.alpha432.oyvey.util.BuildConfig;
|
||||
import me.alpha432.oyvey.util.TextUtil;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.SharedConstants;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class OyVey implements ModInitializer, ClientModInitializer {
|
||||
public static final String NAME = "OyVey";
|
||||
public static final String VERSION = SharedConstants.getCurrentVersion().name();
|
||||
public static float TIMER = 1f;
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger("OyVey");
|
||||
@@ -30,6 +28,8 @@ public class OyVey implements ModInitializer, ClientModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
LOGGER.info("Pre-initializing {} v{}",
|
||||
BuildConfig.NAME, BuildConfig.VERSION);
|
||||
eventManager = new EventManager();
|
||||
serverManager = new ServerManager();
|
||||
rotationManager = new RotationManager();
|
||||
@@ -46,6 +46,10 @@ public class OyVey implements ModInitializer, ClientModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
LOGGER.info("Initializing {}", BuildConfig.NAME);
|
||||
|
||||
long startTime = System.nanoTime();
|
||||
|
||||
eventManager.init();
|
||||
moduleManager.init();
|
||||
hudEditorScreen = new HudEditorScreen();
|
||||
@@ -54,5 +58,10 @@ public class OyVey implements ModInitializer, ClientModInitializer {
|
||||
configManager.load();
|
||||
colorManager.init();
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> configManager.save()));
|
||||
|
||||
long endTime = System.nanoTime();
|
||||
|
||||
LOGGER.info("Initialized {} in {}ms",
|
||||
BuildConfig.NAME, (endTime - startTime) / 1000000.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,34 @@
|
||||
package me.alpha432.oyvey.features.modules.hud;
|
||||
|
||||
import me.alpha432.oyvey.OyVey;
|
||||
import me.alpha432.oyvey.event.impl.Render2DEvent;
|
||||
import me.alpha432.oyvey.features.modules.client.HudModule;
|
||||
import me.alpha432.oyvey.features.settings.Setting;
|
||||
import me.alpha432.oyvey.util.BuildConfig;
|
||||
import me.alpha432.oyvey.util.TextUtil;
|
||||
|
||||
public class Watermark extends HudModule {
|
||||
public Setting<String> text = str("Text", OyVey.NAME);
|
||||
public Setting<String> text = str("Text", BuildConfig.NAME);
|
||||
public Setting<Boolean> fullVersion = new Setting<>("FullVersion", false);
|
||||
|
||||
public Watermark() {
|
||||
super("Watermark", "Display watermark", 100, 10);
|
||||
if (BuildConfig.USING_GIT) {
|
||||
register(fullVersion);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void render(Render2DEvent e) {
|
||||
super.render(e);
|
||||
String watermarkString = "{global} %s {} %s";
|
||||
if (fullVersion.getValue() && BuildConfig.USING_GIT) {
|
||||
watermarkString += "/" + BuildConfig.BRANCH + "-" + BuildConfig.HASH;
|
||||
}
|
||||
|
||||
e.getContext().drawString(mc.font,
|
||||
TextUtil.text("{global} %s {} %s", text.getValue(), OyVey.VERSION),
|
||||
TextUtil.text(watermarkString, text.getValue(), BuildConfig.VERSION),
|
||||
(int) getX(), (int) getY(), -1);
|
||||
|
||||
String watermarkString = text.getValue() + " " + OyVey.VERSION;
|
||||
setWidth(mc.font.width(watermarkString));
|
||||
setHeight(mc.font.lineHeight);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user