Search in sources :

Example 31 with Module

use of org.terasology.gestalt.module.Module in project Terasology by MovingBlocks.

the class ModuleDownloadListGeneratorTest method buildSimpleModule.

private Module buildSimpleModule(String id, String version) {
    ModuleMetadata metadata = new ModuleMetadata();
    metadata.setId(new Name(id));
    if (version != null) {
        metadata.setVersion(new Version(version));
    }
    return new Module(metadata, new EmptyFileSource(), Collections.emptyList(), new Reflections(), (c) -> false);
}
Also used : Version(org.terasology.gestalt.naming.Version) ModuleMetadata(org.terasology.gestalt.module.ModuleMetadata) EmptyFileSource(org.terasology.gestalt.module.resources.EmptyFileSource) Module(org.terasology.gestalt.module.Module) Name(org.terasology.gestalt.naming.Name) Reflections(org.reflections.Reflections)

Example 32 with Module

use of org.terasology.gestalt.module.Module in project Terasology by MovingBlocks.

the class ModuleDownloadListGeneratorTest method testMultipleModulesPartialUpdate.

@Test
public void testMultipleModulesPartialUpdate() throws DependencyResolutionFailedException {
    Module moduleAV1 = buildSimpleModule("myModuleA", "1.0.0");
    Module moduleBV1 = buildSimpleModule("myModuleB", "1.0.0");
    Module moduleBV2 = buildSimpleModule("myModuleB", "2.0.0");
    ModuleRegistry localRegistry = buildRegistry("1.0.0", moduleAV1, moduleBV1);
    DependencyResolver resolver = mockResolver(true, moduleBV1, moduleBV2, buildEngineModule("1.0.0"));
    ModuleDownloadListGenerator listGenerator = new ModuleDownloadListGenerator(localRegistry, resolver);
    assertEquals(Collections.singleton(moduleBV2), buildList(listGenerator));
}
Also used : TableModuleRegistry(org.terasology.gestalt.module.TableModuleRegistry) ModuleRegistry(org.terasology.gestalt.module.ModuleRegistry) Module(org.terasology.gestalt.module.Module) DependencyResolver(org.terasology.gestalt.module.dependencyresolution.DependencyResolver) Test(org.junit.jupiter.api.Test)

Example 33 with Module

use of org.terasology.gestalt.module.Module in project Terasology by MovingBlocks.

the class ModuleDownloadListGeneratorTest method testSingleModuleNeedsUpdate.

@Test
public void testSingleModuleNeedsUpdate() throws DependencyResolutionFailedException {
    Module moduleV1 = buildSimpleModule("myModule", "1.0.0");
    Module moduleV2 = buildSimpleModule("myModule", "2.0.0");
    ModuleRegistry localRegistry = buildRegistry("1.0.0", moduleV1);
    DependencyResolver resolver = mockResolver(true, moduleV2, buildEngineModule("1.0.0"));
    ModuleDownloadListGenerator listGenerator = new ModuleDownloadListGenerator(localRegistry, resolver);
    assertEquals(Collections.singleton(moduleV2), buildList(listGenerator));
}
Also used : TableModuleRegistry(org.terasology.gestalt.module.TableModuleRegistry) ModuleRegistry(org.terasology.gestalt.module.ModuleRegistry) Module(org.terasology.gestalt.module.Module) DependencyResolver(org.terasology.gestalt.module.dependencyresolution.DependencyResolver) Test(org.junit.jupiter.api.Test)

Example 34 with Module

use of org.terasology.gestalt.module.Module in project Terasology by MovingBlocks.

the class ClasspathCompromisingModuleFactoryTest method archiveModuleContainsClass.

@Test
@Disabled("TODO: need a jar module containing classes")
public void archiveModuleContainsClass() throws IOException {
    Module module = factory.createArchiveModule(new File("FIXME.jar"));
    Class<?> someClassInTheModule = module.getModuleManifest().getTypesAnnotatedWith(API.class).iterator().next();
    assertTrue(module.getClassPredicate().test(someClassInTheModule));
    assertFalse(module.getClassPredicate().test(someClassOutsideTheModule));
}
Also used : Module(org.terasology.gestalt.module.Module) File(java.io.File) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 35 with Module

use of org.terasology.gestalt.module.Module in project Terasology by MovingBlocks.

the class ModuleManager method registerPackageModule.

/**
 * Create and register a new module for this package.
 */
public Module registerPackageModule(String packageName) {
    Module module = moduleFactory.createPackageModule(packageName);
    registry.add(module);
    ensureModulesDependOnEngine();
    return module;
}
Also used : Module(org.terasology.gestalt.module.Module)

Aggregations

Module (org.terasology.gestalt.module.Module)51 ModuleManager (org.terasology.engine.core.module.ModuleManager)18 Name (org.terasology.gestalt.naming.Name)17 DependencyResolver (org.terasology.gestalt.module.dependencyresolution.DependencyResolver)13 ModuleMetadata (org.terasology.gestalt.module.ModuleMetadata)11 List (java.util.List)9 Logger (org.slf4j.Logger)9 LoggerFactory (org.slf4j.LoggerFactory)9 SimpleUri (org.terasology.engine.core.SimpleUri)9 UILabel (org.terasology.nui.widgets.UILabel)9 UIText (org.terasology.nui.widgets.UIText)9 DependencyInfo (org.terasology.gestalt.module.dependencyresolution.DependencyInfo)8 ResolutionResult (org.terasology.gestalt.module.dependencyresolution.ResolutionResult)8 Canvas (org.terasology.nui.Canvas)8 Collection (java.util.Collection)7 Comparator (java.util.Comparator)7 Map (java.util.Map)7 Collectors (java.util.stream.Collectors)7 TranslationSystem (org.terasology.engine.i18n.TranslationSystem)7 In (org.terasology.engine.registry.In)7