Skip to content

Commit

Permalink
chore: update gestalt to 8.0.0-SNAPSHOT
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminAmos committed May 24, 2021
1 parent ed2b293 commit d252362
Show file tree
Hide file tree
Showing 287 changed files with 379 additions and 297 deletions.
2 changes: 1 addition & 1 deletion build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {
implementation("dom4j:dom4j:1.6.1")

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

api(kotlin("test"))
}
Expand Down
6 changes: 6 additions & 0 deletions build-logic/src/main/kotlin/terasology-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,14 @@ dependencies {
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")

testImplementation("org.mockito:mockito-junit-jupiter:3.7.7")

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

tasks.withType<JavaCompile> {
inputs.files(sourceSets.main.get().resources.srcDirs)
options.compilerArgs.add("-Aresource=${sourceSets.main.get().resources.srcDirs.joinToString(File.pathSeparator)}")
}

if (project.name == "ModuleTestingEnvironment") {
dependencies {
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 @@ -20,7 +20,7 @@
import org.terasology.engine.core.module.ExternalApiWhitelist;
import org.terasology.engine.core.module.ModuleManager;
import org.terasology.gestalt.module.ModuleEnvironment;
import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;
import org.terasology.engine.testUtil.ModuleManagerFactory;

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

import java.lang.reflect.Constructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.terasology.gestalt.module.Module;
import org.terasology.gestalt.module.ModuleFactory;
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 All @@ -18,6 +18,7 @@

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

public class ClasspathCompromisingModuleFactoryTest {
final static Class<?> someClassOutsideTheModule = ClasspathCompromisingModuleFactory.class;
Expand Down Expand Up @@ -46,10 +47,14 @@ public void archiveModuleContainsClass() throws IOException {

Module module = factory.createArchiveModule(new File("FIXME.jar"));

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

assertTrue(module.getClassPredicate().test(someClassInTheModule));
assertFalse(module.getClassPredicate().test(someClassOutsideTheModule));
assertTrue(module.getClassPredicate().test(someClassInTheModule));
assertFalse(module.getClassPredicate().test(someClassOutsideTheModule));
} catch (ClassNotFoundException ignore) {
fail();
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.jupiter.api.Test;
import org.reflections.Reflections;
import org.terasology.engine.core.TerasologyConstants;
import org.terasology.gestalt.di.index.UrlClassIndex;
import org.terasology.gestalt.module.Module;
import org.terasology.gestalt.module.ModuleMetadata;
import org.terasology.gestalt.module.ModuleRegistry;
Expand Down Expand Up @@ -86,7 +87,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(), UrlClassIndex.byClassLoader(), (c) -> false);
}
private Module buildEngineModule(String version) {
return buildSimpleModule(TerasologyConstants.ENGINE_MODULE.toString(), version);
Expand Down
15 changes: 11 additions & 4 deletions engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,20 @@ dependencies {
implementation group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '4.10'

// Our developed libs
api group: 'org.terasology.gestalt', name: 'gestalt-asset-core', version: '7.1.0-SNAPSHOT'
api group: 'org.terasology.gestalt', name: 'gestalt-module', version: '7.1.0-SNAPSHOT'
api group: 'org.terasology.gestalt', name: 'gestalt-util', version: '7.1.0-SNAPSHOT'
api group: 'org.terasology.gestalt', name: 'gestalt-asset-core', version: '8.0.0-SNAPSHOT'
api group: 'org.terasology.gestalt', name: 'gestalt-module', version: '8.0.0-SNAPSHOT'
api group: 'org.terasology.gestalt', name: 'gestalt-util', version: '8.0.0-SNAPSHOT'
api "com.github.zafarkhaja:java-semver:0.10.0" // ASAP: Remove after https://github.com/MovingBlocks/gestalt/pull/110

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

api group: 'org.terasology', name: 'TeraMath', version: '1.5.0'
api group: 'org.terasology', name: 'splash-screen', version: '1.1.1'
api group: 'org.terasology.jnlua', name: 'JNLua', version: '0.1.0-SNAPSHOT'
api group: 'org.terasology.jnbullet', name: 'JNBullet', version: '1.0.2'
api group: 'org.terasology.nui', name: 'nui', version: '3.0.0-SNAPSHOT'
api group: 'org.terasology.nui', name: 'nui-reflect', version: '3.0.0-SNAPSHOT'
api group: 'org.terasology.nui', name: 'nui-gestalt7', version: '3.0.0-SNAPSHOT'
api group: 'org.terasology.nui', name: 'nui-gestalt', version: '3.0.0-SNAPSHOT'


// Wildcard dependency to catch any libs provided with the project (remote repo preferred instead)
Expand All @@ -129,6 +131,11 @@ dependencies {
api(project(":subsystems:TypeHandlerLibrary"))
}

compileJava {
inputs.files sourceSets.main.resources.srcDirs
options.compilerArgs = ["-Aresource=${sourceSets.main.resources.srcDirs.join(File.pathSeparator)}"]
}

// Instructions for packaging a jar file for the engine
jar {
// Unlike the content modules Gradle grabs the assets as they're in a resources directory. Need to avoid dupes tho
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,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 @@ -16,4 +16,4 @@

@API package org.terasology.engine.audio;

import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;
12 changes: 6 additions & 6 deletions engine/src/main/java/org/terasology/engine/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
import org.terasology.engine.core.TerasologyConstants;
import org.terasology.engine.core.subsystem.Resolution;
import org.terasology.engine.entitySystem.Component;
import org.terasology.gestalt.naming.Version;
import org.terasology.gestalt.naming.gson.NameTypeAdapter;
import org.terasology.gestalt.naming.gson.VersionTypeAdapter;
import org.terasology.input.Input;
import org.terasology.context.annotation.API;
import org.terasology.gestalt.naming.Name;
import org.terasology.engine.utilities.gson.CaseInsensitiveEnumTypeAdapterFactory;
import org.terasology.engine.utilities.gson.InputHandler;
import org.terasology.engine.utilities.gson.ResolutionHandler;
import org.terasology.engine.utilities.gson.SetMultimapTypeAdapter;
import org.terasology.engine.utilities.gson.UriTypeAdapterFactory;
import org.terasology.gestalt.module.sandbox.API;
import org.terasology.gestalt.naming.Name;
import org.terasology.gestalt.naming.Version;
import org.terasology.gestalt.naming.gson.NameTypeAdapter;
import org.terasology.gestalt.naming.gson.VersionTypeAdapter;
import org.terasology.input.Input;

import java.io.BufferedReader;
import java.io.BufferedWriter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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 @@ -19,7 +19,7 @@
import java.beans.PropertyChangeListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;
import org.terasology.engine.rendering.world.WorldRendererImpl;
import org.terasology.engine.utilities.subscribables.AbstractSubscribable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
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 @@ -16,7 +16,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 @@ -15,4 +15,4 @@
*/
@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 @@ -16,6 +17,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 @@ -15,7 +15,7 @@
*/
package org.terasology.engine.context;

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

/**
* Provides classes with the utility objects that belong to the context they are running in.
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package org.terasology.engine.core;

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

/**
* A general interface for observers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;
import org.terasology.gestalt.naming.Name;

/**
Expand Down
2 changes: 1 addition & 1 deletion engine/src/main/java/org/terasology/engine/core/Time.java
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;

/**
* The timer manages all time in the game.
Expand Down
2 changes: 1 addition & 1 deletion engine/src/main/java/org/terasology/engine/core/Uri.java
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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.terasology.engine.core.bootstrap;

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

import java.lang.annotation.Annotation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import org.terasology.engine.entitySystem.event.Event;
import org.terasology.engine.entitySystem.systems.BaseComponentSystem;
import org.terasology.gestalt.module.sandbox.API;
import org.terasology.context.annotation.API;

/**
* Event which is triggered when LocalPlayer is setup with a character entity. Allows for detection of when LocalPlayer is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Module createDirectoryModule(ModuleMetadata metadata, File directory) {
Module module = super.createDirectoryModule(metadata, directory);
return new Module(
module.getMetadata(), module.getResources(),
module.getClasspaths(), module.getModuleManifest(),
module.getClasspaths(), module.getClassIndex(),
new ClassesInModule(module));
}

Expand All @@ -48,7 +48,7 @@ public Module createArchiveModule(ModuleMetadata metadata, File archive) throws
Module module = super.createArchiveModule(metadata, archive);
return new Module(
module.getMetadata(), module.getResources(),
module.getClasspaths(), module.getModuleManifest(),
module.getClasspaths(), module.getClassIndex(),
new ClassesInModule(module));
}

Expand All @@ -71,7 +71,8 @@ static class ClassesInModule implements Predicate<Class<?>> {
throw new RuntimeException(e);
}
}).collect(ImmutableSet.toImmutableSet());
classLoaders = module.getModuleManifest().getConfiguration().getClassLoaders();
//classLoaders = module.getModuleManifest().getConfiguration().getClassLoaders();
classLoaders = new ClassLoader[0]; // TODO
name = module.getId().toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.terasology.engine.core.module;

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

import java.io.IOException;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.engine.core.TerasologyConstants;
import org.terasology.gestalt.di.index.UrlClassIndex;
import org.terasology.gestalt.module.Module;
import org.terasology.gestalt.module.ModuleMetadata;
import org.terasology.gestalt.module.ModuleMetadataJsonAdapter;
Expand Down Expand Up @@ -73,7 +74,7 @@ public ModuleRegistry call() throws IOException {

ModuleMetadata meta = metaReader.read(new StringReader(json));
logger.debug("Read module {} - {}", meta.getId(), meta.getVersion());
modules.add(new Module(meta, new EmptyFileSource(), Collections.emptyList(), new Reflections(),
modules.add(new Module(meta, new EmptyFileSource(), Collections.emptyList(), UrlClassIndex.byClassLoader(),
(c) -> false));
}

Expand Down
Loading

0 comments on commit d252362

Please sign in to comment.