Apache Lucene open-source search software
LUCENE-10307: correct module descriptor so that exported packages test passes.
Dawid Weiss003fa44357d8
diff --git a/lucene/analysis/common/src/java-module/module-info.java b/lucene/analysis/common/src/java-module/module-info.javaindex 00db3a91fe4..e736a9532f0 100644--- a/lucene/analysis/common/src/java-module/module-info.java+++ b/lucene/analysis/common/src/java-module/module-info.java@@ -31,6 +31,7 @@ module org.apache.lucene.analysis.common {exports org.apache.lucene.analysis.ckb;exports org.apache.lucene.analysis.classic;exports org.apache.lucene.analysis.commongrams;+ exports org.apache.lucene.analysis.compound.hyphenation;exports org.apache.lucene.analysis.compound;exports org.apache.lucene.analysis.core;exports org.apache.lucene.analysis.custom;@@ -83,7 +84,10 @@ module org.apache.lucene.analysis.common {exports org.apache.lucene.analysis.tr;exports org.apache.lucene.analysis.util;exports org.apache.lucene.analysis.wikipedia;+ exports org.apache.lucene.collation.tokenattributes;exports org.apache.lucene.collation;+ exports org.tartarus.snowball.ext;+ exports org.tartarus.snowball;provides org.apache.lucene.analysis.CharFilterFactory withorg.apache.lucene.analysis.charfilter.HTMLStripCharFilterFactory,diff --git a/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestModularLayer.java b/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestModularLayer.javaindex 14ed2640c67..56270899060 100644--- a/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestModularLayer.java+++ b/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestModularLayer.java@@ -245,15 +245,35 @@ public class TestModularLayer {TreeMap::new));}- /** Ensure all open packages in the descriptor are in sync with the module's actual content. */+ /**+ * Ensure all exported packages in the descriptor are in sync with the module's Java classes.+ *+ * <p>This test should be progressively tuned so that certain internal packages are hidden in the+ * module layer.+ */@Testpublic void testAllOpenPackagesInSync() throws IOException {for (var module : allCoreModules) {- Set<String> modulePackages = getExportedModulePackages(module);Set<String> jarPackages = getJarPackages(module);- Assertions.assertThat(modulePackages)+ if (module.descriptor().name().equals("org.apache.lucene.luke")) {+ jarPackages.removeIf(+ entry -> {+ // Luke's packages are not exported.+ return entry.startsWith("org.apache.lucene.luke");+ });+ }++ Set<ModuleDescriptor.Exports> moduleExports = module.descriptor().exports();+ Assertions.assertThat(moduleExports).as("Exported packages in module: " + module.descriptor().name())+ .allSatisfy(+ export -> {+ Assertions.assertThat(export.targets())+ .as("We only support unqualified exports for now?")+ .isEmpty();+ })+ .map(ModuleDescriptor.Exports::source).containsExactlyInAnyOrderElementsOf(jarPackages);}}@@ -269,18 +289,7 @@ public class TestModularLayer {&& !entry.endsWith("/")).map(entry -> entry.replaceAll("/[^/]+$", "")).map(entry -> entry.replace('/', '.'))- .filter(- entry -> {- // Filter out luke's packages. They're not exported.- return !entry.startsWith("org.apache.lucene.luke");- }).collect(Collectors.toCollection(TreeSet::new));}}-- private Set<String> getExportedModulePackages(ModuleReference module) {- return module.descriptor().exports().stream()- .map(export -> export.toString())- .collect(Collectors.toCollection(TreeSet::new));- }}