Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade to Gestalt 8 #5267

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {
implementation("org.jgrapht:jgrapht-core:1.5.0")

// for inspecting modules
implementation("org.terasology.gestalt:gestalt-module:7.2.0")
implementation("org.terasology.gestalt:gestalt-module:8.0.0-SNAPSHOT")

// plugins we configure
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:5.2.3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class ModuleMetadataForGradle(private val moduleConfig: ModuleMetadata) {
}

private fun versionStringFromGestaltDependency(gestaltDependency: DependencyInfo): String {
val version = if (gestaltDependency.versionPredicate() is VersionRange) {
gestaltDependency.versionPredicate().toString()
val version = if (gestaltDependency.versionRange() is VersionRange) {
gestaltDependency.versionRange().toString()
} else {
// TODO: gradle-compatible version expressions for gestalt dependencies
// https://github.com/MovingBlocks/gestalt/issues/114
Expand Down
13 changes: 12 additions & 1 deletion build-logic/src/main/kotlin/terasology-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ dependencies {
implementation(group = "org.terasology.engine", name = "engine", version = moduleMetadata.engineVersion())
testImplementation(group = "org.terasology.engine", name = "engine-tests", version = moduleMetadata.engineVersion())

annotationProcessor("org.terasology.gestalt:gestalt-inject-java:8.0.0-SNAPSHOT")

for ((gradleDep, optional) in moduleMetadata.moduleDependencies()) {
if (optional) {
// `optional` module dependencies are ones it does not require for runtime
Expand Down Expand Up @@ -144,8 +146,17 @@ tasks.named("processResources") {
dependsOn("syncAssets", "syncOverrides", "syncDeltas", "syncModuleInfo")
}

tasks.named("compileJava") {
tasks.named<JavaCompile>("compileJava") {
dependsOn("processResources")
// Create an asset list during compilation (needed for Gestalt 8)
inputs.files(sourceSets.main.get().resources.srcDirs)
options.compilerArgs = arrayListOf("-Aresource=${sourceSets.main.get().resources.srcDirs.joinToString(File.pathSeparator)}")
}
tasks.named<JavaCompile>("compileTestJava") {
dependsOn("processResources")
// Create an asset list during compilation (needed for Gestalt 8)
inputs.files(sourceSets.test.get().resources.srcDirs)
options.compilerArgs = arrayListOf("-Aresource=${sourceSets.test.get().resources.srcDirs.joinToString(File.pathSeparator)}")
}

tasks.named<Test>("test") {
Expand Down
15 changes: 14 additions & 1 deletion engine-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ dependencies {
implementation("com.google.protobuf:protobuf-java:3.16.1")
implementation("org.terasology:reflections:0.9.12-MB")

implementation("com.github.zafarkhaja:java-semver:0.10.2")

annotationProcessor("org.terasology.gestalt:gestalt-inject-java:8.0.0-SNAPSHOT")

implementation("org.terasology.joml-ext:joml-test:0.1.0")

testImplementation("ch.qos.logback:logback-classic:1.4.14") {
Expand Down Expand Up @@ -91,8 +95,17 @@ tasks.register<Copy>("copyResourcesToClasses") {
into(sourceSets["main"].output.classesDirs.first())
}

tasks.named("compileJava") {
tasks.named<JavaCompile>("compileJava") {
dependsOn("copyResourcesToClasses")
// Create an asset list during compilation (needed for Gestalt 8)
inputs.files(sourceSets.main.get().resources.srcDirs)
options.compilerArgs = arrayListOf("-Aresource=${sourceSets.main.get().resources.srcDirs.joinToString(File.pathSeparator)}")
}
tasks.named<JavaCompile>("compileTestJava") {
dependsOn("copyResourcesToClasses")
// Create an asset list during compilation (needed for Gestalt 8)
inputs.files(sourceSets.test.get().resources.srcDirs)
options.compilerArgs = arrayListOf("-Aresource=${sourceSets.test.get().resources.srcDirs.joinToString(File.pathSeparator)}")
}

tasks.withType<Jar> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package org.terasology.unittest;

import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;

@API
public class ExampleClass implements ExampleInterface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package org.terasology.unittest;

import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;

@API
public interface ExampleInterface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
@API
package org.terasology.unittest.stubs;

import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
@API
package org.terasology.unittest.worlds;

import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.terasology.engine.core.module.ModuleManager;
import org.terasology.engine.testUtil.ModuleManagerFactory;
import org.terasology.gestalt.module.ModuleEnvironment;
import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;

import java.net.URL;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.terasology.engine.core.module.ModuleManager;
import org.terasology.engine.testUtil.ModuleManagerFactory;
import org.terasology.gestalt.module.ModuleEnvironment;
import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.junit.jupiter.api.Test;
import org.terasology.gestalt.module.Module;
import org.terasology.gestalt.module.ModuleMetadata;
import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;
import org.terasology.gestalt.naming.Name;
import org.terasology.gestalt.naming.Version;
import org.terasology.unittest.ExampleClass;
Expand Down Expand Up @@ -56,9 +56,13 @@ public void directoryModuleContainsClass() {
public void archiveModuleContainsClass() throws IOException {
Module module = factory.createArchiveModule(new File("FIXME.jar"));

Class<?> someClassInTheModule = module.getModuleManifest().getTypesAnnotatedWith(API.class).iterator().next();
String someClassInTheModule = module.getClassIndex().getTypesAnnotatedWith(API.class.getName()).iterator().next();

assertTrue(module.getClassPredicate().test(someClassInTheModule));
try {
assertTrue(module.getClassPredicate().test(Class.forName(someClassInTheModule)));
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
assertFalse(module.getClassPredicate().test(SOME_CLASS_OUTSIDE_THE_MODULE));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.reflections.Reflections;
import org.terasology.engine.core.TerasologyConstants;
import org.terasology.gestalt.di.index.CompoundClassIndex;
import org.terasology.gestalt.module.Module;
import org.terasology.gestalt.module.ModuleMetadata;
import org.terasology.gestalt.module.ModuleRegistry;
Expand Down Expand Up @@ -86,7 +86,7 @@ private Module buildSimpleModule(String id, String version) {
if (version != null) {
metadata.setVersion(new Version(version));
}
return new Module(metadata, new EmptyFileSource(), Collections.emptyList(), new Reflections(), (c) -> false);
return new Module(metadata, new EmptyFileSource(), Collections.emptyList(), new CompoundClassIndex(), (c) -> false);
}
private Module buildEngineModule(String version) {
return buildSimpleModule(TerasologyConstants.ENGINE_MODULE.toString(), version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.junit.jupiter.MockitoExtension;
import org.reflections.Reflections;
import org.terasology.engine.config.flexible.AutoConfig;
import org.terasology.engine.core.PathManager;
import org.terasology.engine.core.PathManagerProvider;
import org.terasology.engine.core.subsystem.EngineSubsystem;
import org.terasology.engine.logic.permission.PermissionSetComponent;
import org.terasology.engine.world.block.structure.AttachSupportRequiredComponent;
import org.terasology.gestalt.di.index.CompoundClassIndex;
import org.terasology.gestalt.module.Module;
import org.terasology.gestalt.module.ModuleEnvironment;
import org.terasology.gestalt.module.ModuleMetadata;
Expand Down Expand Up @@ -59,7 +59,7 @@ private Module getEmptyTestModule() {
new ModuleMetadata(new Name("EmptyTestModule"), new Version("0.0.1")),
new EmptyFileSource(),
Collections.emptyList(),
new Reflections(),
new CompoundClassIndex(),
(clazz) -> false
);
}
Expand Down Expand Up @@ -127,7 +127,7 @@ public void engineModuleContainsSubsystems() {
environment = manager.getEnvironment();
engineModule = environment.get(ENGINE_MODULE);

assertThat(engineModule.getModuleManifest().getSubTypesOf(EngineSubsystem.class)).contains(subsystem);
assertThat(engineModule.getClassIndex().getSubtypesOf(EngineSubsystem.class.getName())).contains(subsystem.getName());

assertThat(environment.getSubtypesOf(EngineSubsystem.class)).contains(subsystem);

Expand Down
34 changes: 26 additions & 8 deletions engine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,25 @@ dependencies {
}
implementation("net.logstash.logback:logstash-logback-encoder:7.4")

// JSemVer (Semantic Versioning) - A dependency of Gestalt
implementation("com.github.zafarkhaja:java-semver:0.10.2")

// Our developed libs
api("org.terasology.gestalt:gestalt-asset-core:7.2.1-SNAPSHOT")
api("org.terasology.gestalt:gestalt-module:7.2.1-SNAPSHOT")
api("org.terasology.gestalt:gestalt-entity-system:7.2.1-SNAPSHOT")
api("org.terasology.gestalt:gestalt-util:7.2.1-SNAPSHOT")
api("org.terasology.gestalt:gestalt-asset-core:8.0.0-SNAPSHOT")
api("org.terasology.gestalt:gestalt-module:8.0.0-SNAPSHOT")
api("org.terasology.gestalt:gestalt-entity-system:8.0.0-SNAPSHOT")
api("org.terasology.gestalt:gestalt-util:8.0.0-SNAPSHOT")
api("org.terasology.gestalt:gestalt-inject:8.0.0-SNAPSHOT")

annotationProcessor("org.terasology.gestalt:gestalt-inject-java:8.0.0-SNAPSHOT")

api("org.terasology:TeraMath:1.5.0")
api("org.terasology:splash-screen:1.1.1")
api("org.terasology.jnlua:JNLua:0.1.0-SNAPSHOT")
api("org.terasology.jnbullet:JNBullet:1.0.4")
api("org.terasology.nui:nui:3.0.0")
api("org.terasology.nui:nui-reflect:3.0.0")
api("org.terasology.nui:nui-gestalt7:3.0.0")
api("org.terasology.nui:nui:4.0.0-SNAPSHOT")
api("org.terasology.nui:nui-reflect:4.0.0-SNAPSHOT")
api("org.terasology.nui:nui-gestalt:4.0.0-SNAPSHOT")


// Wildcard dependency to catch any libs provided with the project (remote repo preferred instead)
Expand Down Expand Up @@ -206,11 +212,23 @@ tasks.register<Copy>("copyResourcesToClasses") {
into(sourceSets["main"].output.classesDirs.first())
}

tasks.named("compileJava") {
tasks.named<JavaCompile>("compileJava") {
dependsOn(
tasks.named("copyResourcesToClasses"),
tasks.named("createVersionInfoFile")
)
// Create an asset list during compilation (needed for Gestalt 8)
inputs.files(sourceSets.main.get().resources.srcDirs)
options.compilerArgs = arrayListOf("-Aresource=${sourceSets.main.get().resources.srcDirs.joinToString(File.pathSeparator)}")
}
tasks.named<JavaCompile>("compileTestJava") {
dependsOn(
tasks.named("copyResourcesToClasses"),
tasks.named("createVersionInfoFile")
)
// Create an asset list during compilation (needed for Gestalt 8)
inputs.files(sourceSets.test.get().resources.srcDirs)
options.compilerArgs = arrayListOf("-Aresource=${sourceSets.test.get().resources.srcDirs.joinToString(File.pathSeparator)}")
}

// Instructions for packaging a jar file for the engine
Expand Down
3 changes: 2 additions & 1 deletion engine/src/main/java/org/terasology/engine/audio/Sound.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public abstract class Sound<T extends AssetData> extends Asset<T> implements org
* @param assetType The asset type this asset belongs to.
*/
protected Sound(ResourceUrn urn, AssetType<?, T> assetType, DisposableResource resource) {
super(urn, assetType, resource);
super(urn, assetType);
setDisposableResource(resource);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
*/
@API package org.terasology.engine.audio.events;

import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

@API package org.terasology.engine.audio;

import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.terasology.engine.utilities.gson.SetMultimapTypeAdapter;
import org.terasology.engine.utilities.gson.UriTypeAdapterFactory;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;
import org.terasology.gestalt.naming.Name;
import org.terasology.gestalt.naming.Version;
import org.terasology.gestalt.naming.gson.NameTypeAdapter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package org.terasology.engine.config;

import org.terasology.engine.core.subsystem.Resolution;
import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;
import org.terasology.engine.rendering.cameras.PerspectiveCameraSettings;
import org.terasology.engine.rendering.nui.layers.mainMenu.videoSettings.DisplayModeSetting;
import org.terasology.engine.rendering.nui.layers.mainMenu.videoSettings.ScreenshotSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.engine.utilities.subscribables.AbstractSubscribable;
import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
package org.terasology.engine.config.facade;

import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;

/**
* TelemetryConfiguration is a wrapper for {@link org.terasology.engine.config.TelemetryConfig}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.google.common.collect.ImmutableList;
import org.reflections.ReflectionUtils;
import org.terasology.context.annotation.IndexInherited;
import org.terasology.engine.config.flexible.internal.SettingBuilder;
import org.terasology.engine.config.flexible.internal.SettingImplBuilder;
import org.terasology.engine.core.SimpleUri;
Expand All @@ -18,6 +19,7 @@
* Represents a config class that will be automatically initialized and rendered by the engine.
* All settings must be contained in {@code public static} fields of type {@link Setting}.
*/
@IndexInherited
public abstract class AutoConfig {
private SimpleUri id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package org.terasology.engine.config.flexible;

import org.terasology.engine.config.flexible.constraints.SettingConstraint;
import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;
import org.terasology.reflection.TypeInfo;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// SPDX-License-Identifier: Apache-2.0
@API package org.terasology.engine.config.flexible.constraints;

import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
package org.terasology.engine.config.flexible.ui;

import org.terasology.context.annotation.IndexInherited;
import org.terasology.engine.config.flexible.Setting;
import org.terasology.engine.config.flexible.constraints.SettingConstraint;
import org.terasology.nui.UIWidget;
Expand All @@ -17,6 +18,7 @@
* @param <T> type of setting
* @param <C> concrete type of {@link SettingConstraint}
*/
@IndexInherited
public abstract class ConstraintWidgetFactory<T, C extends SettingConstraint<T>> {
private Setting<T> setting;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
package org.terasology.engine.context;

import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;

import java.util.NoSuchElementException;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
package org.terasology.engine.core;

import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;
import org.terasology.gestalt.naming.Name;

import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.terasology.engine.registry.InjectionHelper;
import org.terasology.gestalt.module.Module;
import org.terasology.gestalt.module.ModuleEnvironment;
import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;
import org.terasology.gestalt.naming.Name;

import java.util.List;
Expand Down
Loading
Loading