mirror of https://github.com/apache/lucene.git
LUCENE-10307: correct module descriptor so that exported packages test passes.
This commit is contained in:
parent
51d93635aa
commit
003fa44357
|
@ -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 with
|
||||
org.apache.lucene.analysis.charfilter.HTMLStripCharFilterFactory,
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
@Test
|
||||
public 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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue