mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
A settings class whose @Feature has no key fails the load naming the module, the class and the key to add
This commit is contained in:
1 parent
6757cbdd0f
commit
f8d85dcd5e
5 files changed
+91
-8
No files matched your search
@@ -632,6 +632,35 @@ class PackModulesTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void settingsWithoutAKeyFailNamingTheModuleTheClassAndTheKeyToAdd(@TempDir Path build) {
|
||||
var apiWithoutKeys = new TestModuleJar().source("com.volmit.config.Feature", """
|
||||
package com.volmit.config;
|
||||
import java.lang.annotation.*;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface Feature {
|
||||
String id();
|
||||
String name();
|
||||
com.volmit.FeatureAttachment.Target[] targets();
|
||||
}
|
||||
""").writeInto(build, "api-without-keys.jar");
|
||||
module("pack.old.Old", "old:flora", """
|
||||
public void register(com.volmit.FeatureRegistry registry) { registry.registerSettings(Patch.class); }
|
||||
@com.volmit.config.Feature(id = "old:flora/wild-patch", name = "Patch", targets = com.volmit.FeatureAttachment.Target.BIOME)
|
||||
public static final class Patch implements com.volmit.IrisFeature {}
|
||||
""", NO_STAGES)
|
||||
.compileAgainstOlderApi(apiWithoutKeys)
|
||||
.writeInto(pack, "old.jar");
|
||||
|
||||
try (var packModules = PackModules.load(pack)) {
|
||||
assertEquals("Module old:flora from " + origin("old.jar") + ": The @Feature of settings class pack.old.Old$Patch"
|
||||
+ " has no key, the JSON field packs write the settings under; add key = \"floraWildPatch\" (or"
|
||||
+ " another plain field name) to it and rebuild the jar",
|
||||
failure(() -> LoadedModules.load(packModules.modules(), Map.of(), Set.of(), Set.of())));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void duplicateModuleIdsAcrossJarsFailNamingBothJars() {
|
||||
module("pack.one.Duplicate", "dup:core", NO_MEMBERS, NO_STAGES).writeInto(pack, "one.jar");
|
||||
|
||||
@@ -94,6 +94,14 @@ public final class TestModuleJar {
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Puts a jar or class directory before the API on the compile classpath, so the sources compile against an
|
||||
* older copy of an API class it holds; it is not packaged.
|
||||
*/
|
||||
public TestModuleJar compileAgainstOlderApi(Path classes) {
|
||||
classpath.addFirst(classes);
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Compiles against wherever {@code type} was loaded from, such as a host library jar. */
|
||||
public TestModuleJar compileAgainstHostOf(Class<?> type) {
|
||||
return compileAgainst(classesOf(type));
|
||||
|
||||
Reference in new issue
Block a user