mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +00:00
Batch 6 part 3: structure locating, decoding contract, minor cuts
Finding 45: StructureLocator is the one locating service (startedStructures, locatableStarts, locateStart, ChunkFilter moved from VanillaStructures). StartMemo is one opaque non-empty text. VanillaStructureStart.identity is deleted; the host only stored it. useExpansionHack and legacyAir stay: both mirror platform structure behaviour any structure module needs. Finding 46: DESIGN.md documents one decoding contract (fields read by name, absent or null members keep the initialiser, unknown enum names are errors, the host never writes null). Value type getters stop null-guarding. NoiseStyle.cacheSize is deleted. @Desc texts rewritten. multiplier stays on NoiseStyle: it is also an object placement's warp strength. Finding 47: LinkedBiomes moves to world and takes the dimension's settings as PackSettings. Optional packages move from ModuleInfo to the jar manifest (Iris-Optional-Packages); PackageName moves into the host. PlacementRequest.id is dropped (nothing read it).
This commit is contained in:
1 parent
6b24e6f150
commit
1bc91df048
30 files changed
+308
-314
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package com.volmit.host;
|
||||
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.PackageName;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.volmit.host;
|
||||
|
||||
import com.volmit.PackageName;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.volmit.host;
|
||||
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.PackageName;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/** Classes a module jar uses that neither its pack, Iris nor the JDK has, usually optional
|
||||
* dependencies of a library the jar bundles, and that the jar's module does not declare
|
||||
* {@linkplain ModuleInfo#optionalPackages() optional}. The jar still loads; code that needs one of
|
||||
* dependencies of a library the jar bundles, and that the jar's manifest does not declare optional
|
||||
* ({@value ModuleJar#OPTIONAL_PACKAGES_ATTRIBUTE}). The jar still loads; code that needs one of
|
||||
* these classes throws {@link NoClassDefFoundError} when it runs.
|
||||
*
|
||||
* @param origin the jar path relative to its pack
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -19,6 +20,7 @@ import java.util.SortedSet;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
/** One jar in a pack's modules directory, the entry classes it names and the classes it holds,
|
||||
@@ -31,9 +33,15 @@ import java.util.zip.ZipFile;
|
||||
* modules as it lists. The host reads that file from this jar only:
|
||||
* {@code ServiceLoader} would also return providers from parent class loaders and could not tell
|
||||
* which jar a broken entry came from.
|
||||
*
|
||||
* <p>The optional packages are those the jar's manifest lists under {@value #OPTIONAL_PACKAGES_ATTRIBUTE}, separated
|
||||
* by spaces or commas: packages, with their subpackages, whose classes the jar uses but expects may be absent.
|
||||
*/
|
||||
record ModuleJar(Path path, String origin, List<String> entryClasses, List<JarClass> classes) {
|
||||
record ModuleJar(Path path, String origin, List<String> entryClasses, List<JarClass> classes,
|
||||
List<PackageName> optionalPackages) {
|
||||
static final String ENTRY_POINT_FILE = "META-INF/services/" + IrisModule.class.getName();
|
||||
static final String OPTIONAL_PACKAGES_ATTRIBUTE = "Iris-Optional-Packages";
|
||||
private static final String OPTIONAL_PACKAGE_SEPARATORS = "[\\s,]+";
|
||||
private static final String COMMENT_START = "#";
|
||||
private static final String CLASS_FILE_SUFFIX = ".class";
|
||||
private static final String MODULE_DESCRIPTOR = "module-info" + CLASS_FILE_SUFFIX;
|
||||
@@ -44,6 +52,7 @@ record ModuleJar(Path path, String origin, List<String> entryClasses, List<JarCl
|
||||
Objects.requireNonNull(origin, "origin");
|
||||
entryClasses = List.copyOf(entryClasses);
|
||||
classes = List.copyOf(classes);
|
||||
optionalPackages = List.copyOf(optionalPackages);
|
||||
}
|
||||
|
||||
/** A class in the jar, by binary name, and the binary names of the classes it links against. */
|
||||
@@ -63,7 +72,8 @@ record ModuleJar(Path path, String origin, List<String> entryClasses, List<JarCl
|
||||
try (var file = openAsClassLoaderSeesIt(jar)) {
|
||||
var entryClasses = requireEntryClasses(origin, readEntryClasses(file));
|
||||
var classEntries = findClassEntries(file);
|
||||
return new ModuleJar(jar, origin, entryClasses, readClasses(origin, file, classEntries));
|
||||
return new ModuleJar(jar, origin, entryClasses, readClasses(origin, file, classEntries),
|
||||
readOptionalPackages(origin, file.getManifest()));
|
||||
} catch (IOException exception) {
|
||||
throw new ModuleLoadException(null, origin, "Module jar " + origin + " is not a readable jar", exception);
|
||||
}
|
||||
@@ -96,6 +106,22 @@ record ModuleJar(Path path, String origin, List<String> entryClasses, List<JarCl
|
||||
return DiscoveredModule.fromJar(module, readIdentity(entryClass, module), origin);
|
||||
}
|
||||
|
||||
private static List<PackageName> readOptionalPackages(String origin, Manifest manifest) {
|
||||
var declared = manifest == null ? null : manifest.getMainAttributes().getValue(OPTIONAL_PACKAGES_ATTRIBUTE);
|
||||
if (declared == null || declared.isBlank()) {
|
||||
return List.of();
|
||||
}
|
||||
return Arrays.stream(declared.trim().split(OPTIONAL_PACKAGE_SEPARATORS))
|
||||
.map(name -> requireOptionalPackage(origin, name))
|
||||
.toList();
|
||||
}
|
||||
|
||||
private static PackageName requireOptionalPackage(String origin, String name) {
|
||||
return PackageName.tryParse(name).orElseThrow(() -> ModuleLoadException.ofJar(origin, "Module jar " + origin
|
||||
+ " declares optional package '" + name + "' in " + OPTIONAL_PACKAGES_ATTRIBUTE + ", which is not a package"
|
||||
+ " name; name a package such as org.slf4j, which covers that package and its subpackages"));
|
||||
}
|
||||
|
||||
/** Opens the jar with the runtime's multi-release version, like the pack class loader does, so
|
||||
* class names below match the classes that loader can define.
|
||||
*/
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.stream.Stream;
|
||||
* a class that Iris hides from modules or that is missing from an exposed package.
|
||||
* Classes that nobody has are not an error, because the JVM only needs them when code that uses
|
||||
* them runs; they are reported as {@link #missingClasses()}, except those in the optional packages
|
||||
* the jar's module declares in its {@link com.volmit.ModuleInfo}.
|
||||
* the jar's manifest declares ({@value ModuleJar#OPTIONAL_PACKAGES_ATTRIBUTE}).
|
||||
*
|
||||
* <p>A successful load logs one INFO summary of the pack's modules through a {@link System.Logger}, by
|
||||
* default the one named after this class, or the host's from {@link ModuleHost#loggingTo}, and one
|
||||
@@ -188,7 +188,7 @@ public final class PackModules implements AutoCloseable {
|
||||
var loader = newPackClassLoader(packRoot, jars, host);
|
||||
try {
|
||||
var modules = createModules(jars, loader, snapshot, logger);
|
||||
return new PackModules(modules, withoutDeclaredOptional(missingClasses, modules), loader, snapshot);
|
||||
return new PackModules(modules, withoutDeclaredOptional(missingClasses, jars), loader, snapshot);
|
||||
} catch (RuntimeException | Error failure) {
|
||||
closeAfterFailure(loader, failure);
|
||||
throw failure;
|
||||
@@ -219,16 +219,11 @@ public final class PackModules implements AutoCloseable {
|
||||
.toList();
|
||||
}
|
||||
|
||||
/** A module's optional packages excuse only its own jar's missing classes; a jar with several
|
||||
* modules is excused by the optional packages of all of them. They are read from {@code info()},
|
||||
* so this runs after the entry classes exist; errors were decided before that and never depend on them.
|
||||
*/
|
||||
private static List<MissingClasses> withoutDeclaredOptional(List<MissingClasses> missingClasses, List<DiscoveredModule> modules) {
|
||||
var optionalPackages = modules.stream()
|
||||
.collect(Collectors.groupingBy(DiscoveredModule::origin,
|
||||
Collectors.flatMapping(found -> found.info().optionalPackages().stream(), Collectors.toList())));
|
||||
/** A jar's optional packages excuse only its own missing classes; errors were decided before and never depend on them. */
|
||||
private static List<MissingClasses> withoutDeclaredOptional(List<MissingClasses> missingClasses, List<ModuleJar> jars) {
|
||||
var optionalPackages = jars.stream().collect(Collectors.toMap(ModuleJar::origin, ModuleJar::optionalPackages));
|
||||
return missingClasses.stream()
|
||||
.map(jar -> jar.outside(optionalPackages.get(jar.origin())))
|
||||
.map(jar -> jar.outside(optionalPackages.getOrDefault(jar.origin(), List.of())))
|
||||
.filter(Predicate.not(MissingClasses::isEmpty))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.volmit.host;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
/** A Java package name that stands for the package and all its subpackages. Only whole package
|
||||
* names match: {@code com.volmit} contains {@code com.volmit.stage.Stage} but not
|
||||
* {@code com.volmitx.Fake}.
|
||||
*/
|
||||
record PackageName(String name) implements Comparable<PackageName> {
|
||||
private static final char SEPARATOR = '.';
|
||||
private static final String SEPARATOR_PATTERN = "\\.";
|
||||
|
||||
public PackageName {
|
||||
Objects.requireNonNull(name, "name");
|
||||
if (!isPackageName(name)) throw new IllegalArgumentException("'" + name + "' is not a package name");
|
||||
}
|
||||
|
||||
/** The package {@code name} denotes, if it is a package name. A trailing dot is accepted; blank
|
||||
* names, wildcards and anything else that is not a package name give an empty result.
|
||||
*/
|
||||
public static Optional<PackageName> tryParse(String name) {
|
||||
Objects.requireNonNull(name, "name");
|
||||
var withoutTrailingDot = name.endsWith(String.valueOf(SEPARATOR)) ? name.substring(0, name.length() - 1) : name;
|
||||
return isPackageName(withoutTrailingDot) ? Optional.of(new PackageName(withoutTrailingDot)) : Optional.empty();
|
||||
}
|
||||
|
||||
/** Whether the class with this binary name is in this package or one of its subpackages. */
|
||||
public boolean contains(String binaryName) {
|
||||
return binaryName.startsWith(name)
|
||||
&& binaryName.length() > name.length()
|
||||
&& binaryName.charAt(name.length()) == SEPARATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() { return name; }
|
||||
|
||||
@Override
|
||||
public int compareTo(PackageName other) { return name.compareTo(other.name); }
|
||||
|
||||
private static boolean isPackageName(String name) {
|
||||
return Arrays.stream(name.split(SEPARATOR_PATTERN, -1)).allMatch(PackageName::isIdentifier);
|
||||
}
|
||||
|
||||
private static boolean isIdentifier(String segment) {
|
||||
return !segment.isEmpty()
|
||||
&& Character.isJavaIdentifierStart(segment.codePointAt(0))
|
||||
&& segment.codePoints().skip(1).allMatch(Character::isJavaIdentifierPart);
|
||||
}
|
||||
}
|
||||
@@ -79,23 +79,6 @@ class ApiValuesTest {
|
||||
assertThrows(NullPointerException.class, () -> ModuleInfo.of("example:moss", null, "1.0.0"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void moduleInfoDeclaresOptionalPackagesWithTheirSubpackages() {
|
||||
var plain = ModuleInfo.of("example:moss", "Moss", "1.0.0");
|
||||
var info = plain.withOptionalPackages("org.slf4j", "org.apache.logging.");
|
||||
|
||||
assertEquals(List.of(), plain.optionalPackages());
|
||||
assertEquals(List.of(new PackageName("org.slf4j"), new PackageName("org.apache.logging")), info.optionalPackages());
|
||||
assertEquals(List.of(), info.withOptionalPackages().optionalPackages());
|
||||
assertTrue(info.optionalPackages().getFirst().contains("org.slf4j.spi.LocationAwareLogger"));
|
||||
assertFalse(info.optionalPackages().getFirst().contains("org.slf4jx.Logger"));
|
||||
for (var invalid : List.of("", "org.*", "org..slf4j", "1org")) {
|
||||
var failure = assertThrows(IllegalArgumentException.class, () -> plain.withOptionalPackages(invalid));
|
||||
assertTrue(failure.getMessage().startsWith("Optional package '" + invalid + "' of module example:moss is not a package name"),
|
||||
failure.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void moduleInfoTextFitsOnOneLogLine() {
|
||||
for (var broken : List.of("Moss\nINFO forged line", "Moss\r", "Moss\tTabbed", "Moss\u2028Next")) {
|
||||
@@ -155,10 +138,10 @@ class ApiValuesTest {
|
||||
@Test
|
||||
void placementAlignsAnchorsAndCheckedArithmeticNeverWraps() {
|
||||
var object = new GeneratedObject(new BlockBox(-1, -1, -1, 2, 2, 2), new BlockPosition(1, 1, 1), List.of(), List.of());
|
||||
var request = new PlacementRequest(ResourceId.parse("test:placement"), object, new BlockPosition(-16, 64, -16));
|
||||
var request = new PlacementRequest(object, new BlockPosition(-16, 64, -16));
|
||||
assertEquals(new BlockPosition(-16, 64, -16), request.worldPosition(object.anchor()));
|
||||
assertEquals(new BlockBox(-18, 62, -18, -15, 65, -15), request.footprint());
|
||||
var overflow = new PlacementRequest(request.id(), object, new BlockPosition(Integer.MAX_VALUE, 0, 0));
|
||||
var overflow = new PlacementRequest(object, new BlockPosition(Integer.MAX_VALUE, 0, 0));
|
||||
assertThrows(ArithmeticException.class, overflow::footprint);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,17 +104,16 @@ class VanillaStructureValuesTest {
|
||||
assertFalse(start.isUnderground());
|
||||
assertFalse(start.replacesPlatformStart());
|
||||
assertEquals(Optional.empty(), start.memo());
|
||||
var memo = new StartMemo("{\"mode\":\"VACUUM\"}", "null");
|
||||
var memo = new StartMemo("{\"mode\":\"VACUUM\"}");
|
||||
assertEquals(Optional.of(memo), start.withMemo(memo).memo());
|
||||
assertNotEquals(start, start.withMemo(memo));
|
||||
assertEquals(Optional.empty(), start.jigsaw());
|
||||
var underground = start.underground().replacingPlatformStart().withIdentity(-5L)
|
||||
var underground = start.underground().replacingPlatformStart()
|
||||
.withJigsaw(JigsawOverrides.none().withMaxDepth(3));
|
||||
assertTrue(underground.isUnderground());
|
||||
assertTrue(underground.replacesPlatformStart());
|
||||
assertEquals(-5L, underground.identity());
|
||||
assertEquals(Optional.of(JigsawOverrides.none().withMaxDepth(3)), underground.jigsaw());
|
||||
assertEquals(underground, start.withIdentity(-5L).replacingPlatformStart().underground()
|
||||
assertEquals(underground, start.replacingPlatformStart().underground()
|
||||
.withJigsaw(JigsawOverrides.none().withMaxDepth(3)));
|
||||
}
|
||||
|
||||
@@ -133,9 +132,6 @@ class VanillaStructureValuesTest {
|
||||
assertEquals(StartReach.PLATFORM, provider.reach(CITY, true, Optional.empty(), null));
|
||||
assertEquals(VanillaStructureSetup.UNCHANGED, provider.setup(null));
|
||||
assertEquals(VanillaStructureRule.GENERATE, new VanillaStructures() { }.rule(CITY, null));
|
||||
assertEquals(Set.of(), provider.startedStructures(null));
|
||||
assertEquals(Set.of(), provider.locatableStarts(null));
|
||||
assertEquals(LocateResult.NOT_FOUND, provider.locateStart(null, CITY, 0, 0, 8, (chunkX, chunkZ) -> true));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -158,6 +154,9 @@ class VanillaStructureValuesTest {
|
||||
};
|
||||
|
||||
assertEquals(Set.of(CASTLE), locator.placed(null));
|
||||
assertEquals(Set.of(), locator.startedStructures(null), "a locator that starts no platform structure finds none");
|
||||
assertEquals(Set.of(), locator.locatableStarts(null));
|
||||
assertEquals(LocateResult.NOT_FOUND, locator.locateStart(null, CITY, 0, 0, 8, (chunkX, chunkZ) -> true));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -100,7 +100,7 @@ class PlacementLifecyclePortTest {
|
||||
new ObjectBlock(new BlockPosition(1, 0, 0), PLANKS),
|
||||
new ObjectBlock(new BlockPosition(1, 1, 0), PLANKS)),
|
||||
List.of());
|
||||
return new PlacementRequest(ResourceId.parse("test:attempt"), object, new BlockPosition(0, 0, 0));
|
||||
return new PlacementRequest(object,new BlockPosition(0, 0, 0));
|
||||
}
|
||||
|
||||
private static TestTerrain terrain() {
|
||||
|
||||
@@ -6,6 +6,6 @@ import com.volmit.geometry.BlockPosition;
|
||||
/** The world position the object's local anchor is placed at. */
|
||||
public record AnchorResult(BlockPosition anchor) {
|
||||
public BlockPosition worldPosition(PlacementRequest request, BlockPosition local) {
|
||||
return new PlacementRequest(request.id(), request.object(), anchor).worldPosition(local);
|
||||
return new PlacementRequest(request.object(), anchor).worldPosition(local);
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ class PackModulesTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void optionalPackagesOfAnyModuleOfAJarExcuseItsMissingClasses(@TempDir Path build) {
|
||||
void aJarsOptionalPackagesExcuseTheMissingClassesOfAllItsModules(@TempDir Path build) {
|
||||
module("pack.First", "first:core", List.of("org.optional"), NO_MEMBERS, NO_SETUP)
|
||||
.alsoModule("pack.Second", "second:core", using(OPTIONAL_CLASS), NO_SETUP)
|
||||
.compileAgainst(library(build, "optional.jar", OPTIONAL_CLASS))
|
||||
@@ -460,8 +460,8 @@ class PackModulesTest {
|
||||
module("pack.user.User", "user:core", List.of("org.*"), NO_MEMBERS, NO_SETUP).writeInto(pack, "user.jar");
|
||||
|
||||
assertMentions(failure(() -> PackModules.load(pack)),
|
||||
"Module jar " + origin("user.jar") + " has a broken entry point pack.user.User: info() failed",
|
||||
"Optional package 'org.*' of module user:core is not a package name");
|
||||
"Module jar " + origin("user.jar") + " declares optional package 'org.*' in Iris-Optional-Packages,"
|
||||
+ " which is not a package name");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -80,7 +80,7 @@ class StageGraphTest {
|
||||
var object = new GeneratedObject(new BlockBox(0, 0, 0, 2, 1, 1), new BlockPosition(0, 0, 0),
|
||||
List.of(new ObjectBlock(new BlockPosition(0, 0, 0), STONE), new ObjectBlock(new BlockPosition(1, 0, 0), STONE)),
|
||||
List.of());
|
||||
return new PlacementRequest(ResourceId.parse("test:attempt"), object, new BlockPosition(0, 10, 0));
|
||||
return new PlacementRequest(object,new BlockPosition(0, 10, 0));
|
||||
}
|
||||
|
||||
private static MemoryEdit flatEdit() {
|
||||
|
||||
@@ -51,7 +51,7 @@ class StageStreamsTest {
|
||||
private static PlacementRequest request() {
|
||||
var blocks = IntStream.range(0, BLOCKS).mapToObj(x -> new ObjectBlock(new BlockPosition(x, 0, 0), STONE)).toList();
|
||||
var object = new GeneratedObject(new BlockBox(0, 0, 0, BLOCKS, 1, 1), new BlockPosition(0, 0, 0), blocks, List.of());
|
||||
return new PlacementRequest(ResourceId.parse("test:attempt"), object, new BlockPosition(0, 10, 0));
|
||||
return new PlacementRequest(object,new BlockPosition(0, 10, 0));
|
||||
}
|
||||
|
||||
private Map<String, List<Long>> place(ResolvedGraph graph, long invocationSeed) {
|
||||
|
||||
@@ -33,7 +33,9 @@ public final class TestModuleJar {
|
||||
|
||||
private final Map<String, String> sources = new LinkedHashMap<>();
|
||||
private final Map<String, byte[]> resources = new LinkedHashMap<>();
|
||||
private static final String OPTIONAL_PACKAGES_ATTRIBUTE = "Iris-Optional-Packages";
|
||||
private boolean multiRelease;
|
||||
private final List<String> optionalPackages = new ArrayList<>();
|
||||
private final List<String> entryPoints = new ArrayList<>();
|
||||
private final List<Path> classpath = new ArrayList<>(List.of(classesOf(IrisModule.class)));
|
||||
private final List<String> compilerExports = new ArrayList<>();
|
||||
@@ -43,15 +45,16 @@ public final class TestModuleJar {
|
||||
return module(className, moduleId, List.of(), members, install);
|
||||
}
|
||||
|
||||
/** Like {@link #module(String, String, String, String)}, with {@code info()} declaring {@code optionalPackages}. */
|
||||
/** Like {@link #module(String, String, String, String)}, in a jar whose manifest declares {@code optionalPackages}. */
|
||||
public static TestModuleJar module(String className, String moduleId, List<String> optionalPackages, String members, String install) {
|
||||
var info = moduleInfo(moduleId, optionalPackages);
|
||||
return new TestModuleJar().source(className, moduleSource(className, info, members, install)).entryPoint(className);
|
||||
var jar = new TestModuleJar();
|
||||
jar.optionalPackages.addAll(optionalPackages);
|
||||
return jar.source(className, moduleSource(className, moduleInfo(moduleId), members, install)).entryPoint(className);
|
||||
}
|
||||
|
||||
/** Another entry class in the same jar, with the given module id; see {@link #module(String, String, String, String)}. */
|
||||
public TestModuleJar alsoModule(String className, String moduleId, String members, String install) {
|
||||
var info = moduleInfo(moduleId, List.of());
|
||||
var info = moduleInfo(moduleId);
|
||||
return source(className, moduleSource(className, info, members, install)).entryPoint(className);
|
||||
}
|
||||
|
||||
@@ -159,6 +162,9 @@ public final class TestModuleJar {
|
||||
var manifest = new Manifest();
|
||||
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
|
||||
if (multiRelease) manifest.getMainAttributes().put(Attributes.Name.MULTI_RELEASE, "true");
|
||||
if (!optionalPackages.isEmpty()) {
|
||||
manifest.getMainAttributes().putValue(OPTIONAL_PACKAGES_ATTRIBUTE, String.join(" ", optionalPackages));
|
||||
}
|
||||
return manifest;
|
||||
}
|
||||
|
||||
@@ -177,11 +183,8 @@ public final class TestModuleJar {
|
||||
output.closeEntry();
|
||||
}
|
||||
|
||||
private static String moduleInfo(String moduleId, List<String> optionalPackages) {
|
||||
var info = "ModuleInfo.of(\"%s\", \"%s\", \"1.0.0\")".formatted(moduleId, displayName(moduleId));
|
||||
if (optionalPackages.isEmpty()) return info;
|
||||
var packages = optionalPackages.stream().map(name -> '"' + name + '"').collect(Collectors.joining(", "));
|
||||
return info + ".withOptionalPackages(" + packages + ")";
|
||||
private static String moduleInfo(String moduleId) {
|
||||
return "ModuleInfo.of(\"%s\", \"%s\", \"1.0.0\")".formatted(moduleId, displayName(moduleId));
|
||||
}
|
||||
|
||||
private static String moduleSource(String className, String info, String members, String install) {
|
||||
|
||||
Reference in new issue
Block a user