forked from StarOpenSource/Engine
Set java source and target versions
This commit also introduces a warning when running the engine on a Java version higher than the engine source is on
This commit is contained in:
parent
081ac106f4
commit
05b9644eba
4 changed files with 57 additions and 1 deletions
|
@ -153,9 +153,10 @@ public final class Engine extends SubsystemClass {
|
||||||
/**
|
/**
|
||||||
* Initializes the StarOpenSource Engine.
|
* Initializes the StarOpenSource Engine.
|
||||||
*
|
*
|
||||||
|
* @throws IllegalStateException when running in an incompatible environment
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*/
|
*/
|
||||||
public Engine() {
|
public Engine() throws IllegalStateException {
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
instance = this;
|
instance = this;
|
||||||
else
|
else
|
||||||
|
@ -169,6 +170,8 @@ public final class Engine extends SubsystemClass {
|
||||||
|
|
||||||
logger.info("Initializing engine");
|
logger.info("Initializing engine");
|
||||||
initializeClasses(); // Initialize classes
|
initializeClasses(); // Initialize classes
|
||||||
|
if (checkEnvironment())
|
||||||
|
throw new IllegalStateException("Running in an incompatible environment");
|
||||||
populateCrashContent(); // Populate crash content
|
populateCrashContent(); // Populate crash content
|
||||||
cacheEvents(); // Cache event listeners
|
cacheEvents(); // Cache event listeners
|
||||||
startThreads(); // Start threads
|
startThreads(); // Start threads
|
||||||
|
@ -192,6 +195,20 @@ public final class Engine extends SubsystemClass {
|
||||||
logger.info("Initialized sos!engine %engine_version% (commit %engine_git_commit_id_long%-%engine_git_branch%, dirty %engine_git_dirty%) in " + initTime + "ms");
|
logger.info("Initialized sos!engine %engine_version% (commit %engine_git_commit_id_long%-%engine_git_branch%, dirty %engine_git_dirty%) in " + initTime + "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the environment is compatible with the engine build.
|
||||||
|
*
|
||||||
|
* @since v1-alpha4
|
||||||
|
*/
|
||||||
|
private boolean checkEnvironment() {
|
||||||
|
logger.diag("Checking environment");
|
||||||
|
|
||||||
|
if (JvmInformation.getJavaVersion() > EngineInformation.getJavaSource())
|
||||||
|
logger.warn("The StarOpenSource Engine is running on an untested Java version.\nThings may not work as expected or features which can improve performance, stability, compatibility or ease of use may be missing.\nIf you encounter issues, try running a JVM implementing Java " + EngineInformation.getJavaSource());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes all classes.
|
* Initializes all classes.
|
||||||
*
|
*
|
||||||
|
|
|
@ -135,6 +135,33 @@ public final class EngineInformation {
|
||||||
private static String versioningString;
|
private static String versioningString;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the Java version of the engine source.
|
||||||
|
*
|
||||||
|
* @since v1-alpha4
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the Java version of the engine source.
|
||||||
|
*
|
||||||
|
* @return java version of engine source
|
||||||
|
* @since v1-alpha4
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static short javaSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the Java version the engine was compiled against.
|
||||||
|
*
|
||||||
|
* @since v1-alpha4
|
||||||
|
* -- GETTER --
|
||||||
|
* Returns the Java version the engine was compiled against.
|
||||||
|
*
|
||||||
|
* @return java version compiled against
|
||||||
|
* @since v1-alpha4
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static short javaTarget;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains the {@code dirty} value (i.e. if the source tree has been modified).
|
* Contains the {@code dirty} value (i.e. if the source tree has been modified).
|
||||||
*
|
*
|
||||||
|
@ -382,6 +409,9 @@ public final class EngineInformation {
|
||||||
versioningFork = gradleParser.getString("versioningFork");
|
versioningFork = gradleParser.getString("versioningFork");
|
||||||
versioningString = "v" + versioningVersion + "-" + (versioningType == VersionType.RELEASE_CANDIDATE ? "releasecandidate" : versioningType.name().toLowerCase(Locale.ROOT)) + versioningTyperelease + versioningFork;
|
versioningString = "v" + versioningVersion + "-" + (versioningType == VersionType.RELEASE_CANDIDATE ? "releasecandidate" : versioningType.name().toLowerCase(Locale.ROOT)) + versioningTyperelease + versioningFork;
|
||||||
|
|
||||||
|
javaSource = gradleParser.getShort("javaSource");
|
||||||
|
javaTarget = gradleParser.getShort("javaTarget");
|
||||||
|
|
||||||
dependencyJansi = gradleParser.getString("dependencyJansi");
|
dependencyJansi = gradleParser.getString("dependencyJansi");
|
||||||
dependencyReflections = gradleParser.getString("dependencyReflections");
|
dependencyReflections = gradleParser.getString("dependencyReflections");
|
||||||
dependencySlf4j = gradleParser.getString("dependencySlf4j");
|
dependencySlf4j = gradleParser.getString("dependencySlf4j");
|
||||||
|
|
|
@ -96,6 +96,11 @@ allprojects {
|
||||||
group = project.group
|
group = project.group
|
||||||
version = project.versioningVersion + "-" + project.versioningType + project.versioningTyperelease + project.versioningFork
|
version = project.versioningVersion + "-" + project.versioningType + project.versioningTyperelease + project.versioningFork
|
||||||
|
|
||||||
|
java {
|
||||||
|
setSourceCompatibility(JavaVersion.valueOf("VERSION_" + project.javaSource))
|
||||||
|
setTargetCompatibility(JavaVersion.valueOf("VERSION_" + project.javaTarget))
|
||||||
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,10 @@ versioningType=alpha
|
||||||
versioningTyperelease=4
|
versioningTyperelease=4
|
||||||
versioningFork=
|
versioningFork=
|
||||||
|
|
||||||
|
# Java
|
||||||
|
javaSource=22
|
||||||
|
javaTarget=21
|
||||||
|
|
||||||
# Shared Dependencies
|
# Shared Dependencies
|
||||||
dependencyLombok=1.18.32
|
dependencyLombok=1.18.32
|
||||||
dependencyJetbrainsAnnotations=24.1.0
|
dependencyJetbrainsAnnotations=24.1.0
|
||||||
|
|
Loading…
Reference in a new issue