mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Load pack modules from <pack>/modules jars
A module jar names its IrisModule class in META-INF/services/com.volmit.IrisModule. PackModules scans <pack>/modules/*.jar in file name order, loads all jars of a pack through one URLClassLoader whose parent is the API's loader, and closes it when the pack unloads. Modules now reach LoadedModules as DiscoveredModule (module plus origin), so errors name the offending jar: missing or multiple entry points, broken entry classes, duplicate module ids and foreign stage namespaces.
This commit is contained in:
1 parent
e918cd44a8
commit
6388173f19
12 files changed
+606
-29
No files matched your search
@@ -7,6 +7,7 @@ import com.volmit.example.chunk.TerrainModule;
|
||||
import com.volmit.host.ArrayHunk;
|
||||
import com.volmit.host.ChunkRunner;
|
||||
import com.volmit.host.ConfiguredSettings;
|
||||
import com.volmit.host.DiscoveredModule;
|
||||
import com.volmit.host.StageGraphBuilder;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import com.volmit.stage.Pipeline;
|
||||
@@ -25,8 +26,8 @@ class ChunkPipelineTest {
|
||||
|
||||
private static ChunkRunner runner() {
|
||||
var builder = new StageGraphBuilder();
|
||||
builder.install(new GrassModule());
|
||||
builder.install(new TerrainModule());
|
||||
builder.install(DiscoveredModule.builtIn(new GrassModule()));
|
||||
builder.install(DiscoveredModule.builtIn(new TerrainModule()));
|
||||
var graph = builder.resolve(Pipeline.CHUNK);
|
||||
assertEquals(List.of("iris:terrain/surface", "example:grass/top"),
|
||||
graph.stages().stream().map(stage -> stage.stage().id().toString()).toList());
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.volmit.ModuleInfo;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.example.placement.*;
|
||||
import com.volmit.host.ConfiguredSettings;
|
||||
import com.volmit.host.DiscoveredModule;
|
||||
import com.volmit.host.LoadedModules;
|
||||
import com.volmit.host.PlacementRunner;
|
||||
import com.volmit.host.ResolvedGraph;
|
||||
@@ -83,7 +84,7 @@ class PlacementLifecyclePortTest {
|
||||
|
||||
private static ResolvedGraph resolve(List<? extends IrisModule> modules) {
|
||||
var builder = new StageGraphBuilder();
|
||||
modules.forEach(builder::install);
|
||||
modules.stream().map(DiscoveredModule::builtIn).forEach(builder::install);
|
||||
return builder.resolve(Pipeline.PLACEMENT);
|
||||
}
|
||||
|
||||
@@ -196,7 +197,7 @@ class PlacementLifecyclePortTest {
|
||||
|
||||
@Test
|
||||
void loadingThePortCatalogsEveryConditioningSettingsType() {
|
||||
var loaded = LoadedModules.load(PlacementModules.all(), Map.of());
|
||||
var loaded = LoadedModules.load(PlacementModules.builtIns(), Map.of());
|
||||
|
||||
assertEquals(List.of("example:moss", "iris:snow", "iris:stilt"),
|
||||
loaded.catalog().settings().stream().map(settings -> settings.id().toString()).toList());
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.volmit.example.placement;
|
||||
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.host.DiscoveredModule;
|
||||
import java.util.List;
|
||||
|
||||
public final class PlacementModules {
|
||||
@@ -11,4 +12,9 @@ public final class PlacementModules {
|
||||
return List.of(new PrepareModule(), new AnchorModule(), new BlocksModule(),
|
||||
new StiltModule(), new SnowModule(), new MossModule());
|
||||
}
|
||||
|
||||
/** {@link #all()} as modules shipped with the host. */
|
||||
public static List<DiscoveredModule> builtIns() {
|
||||
return all().stream().map(DiscoveredModule::builtIn).toList();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user