diff --git a/dev-tools/scripts/smokeTestRelease.py b/dev-tools/scripts/smokeTestRelease.py index d183fbab7fd..b4699c1ca2a 100755 --- a/dev-tools/scripts/smokeTestRelease.py +++ b/dev-tools/scripts/smokeTestRelease.py @@ -574,10 +574,10 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs): # raise RuntimeError('lucene: file "%s" is missing from artifact %s' % (fileName, artifact)) # in_root_folder.remove(fileName) - expected_folders = ['analysis', 'backward-codecs', 'benchmark', 'classification', 'codecs', 'core', - 'demo', 'expressions', 'facet', 'grouping', 'highlighter', 'join', + expected_folders = ['analysis', 'analysis.tests', 'backward-codecs', 'benchmark', 'classification', 'codecs', 'core', 'core.tests', + 'distribution.tests', 'demo', 'expressions', 'facet', 'grouping', 'highlighter', 'join', 'luke', 'memory', 'misc', 'monitor', 'queries', 'queryparser', 'replicator', - 'sandbox', 'spatial-extras', 'spatial3d', 'suggest', 'test-framework', 'licenses'] + 'sandbox', 'spatial-extras', 'spatial-test-fixtures', 'spatial3d', 'suggest', 'test-framework', 'licenses'] if isSrc: expected_src_root_files = ['build.gradle', 'buildSrc', 'dev-docs', 'dev-tools', 'gradle', 'gradlew', 'gradlew.bat', 'help', 'lucene', 'settings.gradle', 'versions.lock', 'versions.props'] @@ -588,7 +588,7 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs): if len(in_lucene_folder) > 0: raise RuntimeError('lucene: unexpected files/dirs in artifact %s lucene/ folder: %s' % (artifact, in_lucene_folder)) else: - is_in_list(in_root_folder, ['bin', 'docs', 'licenses', 'modules', 'modules-thirdparty']) + is_in_list(in_root_folder, ['bin', 'docs', 'licenses', 'modules', 'modules-thirdparty', 'modules-test-framework']) if len(in_root_folder) > 0: raise RuntimeError('lucene: unexpected files/dirs in artifact %s: %s' % (artifact, in_root_folder)) @@ -657,8 +657,8 @@ def testDemo(run_java, isSrc, version, jdk): indexFilesCmd = 'java -cp "%s" -Dsmoketester=true org.apache.lucene.demo.IndexFiles -index index -docs %s' % (cp, docsDir) searchFilesCmd = 'java -cp "%s" org.apache.lucene.demo.SearchFiles -index index -query lucene' % cp else: - # For binary release, set up classpath as modules. - cp = "--module-path modules" + # For binary release, set up module path. + cp = "--module-path %s" % (sep.join(["modules", "modules-thirdparty"])) docsDir = 'docs' checkIndexCmd = 'java -ea %s --module org.apache.lucene.core/org.apache.lucene.index.CheckIndex index' % cp indexFilesCmd = 'java -Dsmoketester=true %s --module org.apache.lucene.demo/org.apache.lucene.demo.IndexFiles -index index -docs %s' % (cp, docsDir) 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.java index 72be33dbd4a..461a63703b1 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 @@ -18,6 +18,7 @@ package org.apache.lucene.distribution; import java.io.IOException; import java.io.InputStream; +import java.lang.module.Configuration; import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleFinder; import java.lang.module.ModuleReader; @@ -52,11 +53,14 @@ import org.junit.Test; * JUnit, for example). */ public class TestModularLayer extends AbstractLuceneDistributionTest { - /** Only core Lucene modules, no third party modules. */ - private static Set allCoreModules; + /** All Lucene modules (including the test framework), no third party modules. */ + private static Set allLuceneModules; - /** {@link ModuleFinder} resolving only the Lucene modules. */ - private static ModuleFinder coreModulesFinder; + /** {@link ModuleFinder} resolving only the core Lucene modules. */ + private static ModuleFinder allLuceneModulesFinder; + + /** {@link ModuleFinder} resolving Lucene core and third party dependencies. */ + private static ModuleFinder luceneCoreAndThirdPartyModulesFinder; /** * We accept external properties that point to the assembled set of distribution modules and to @@ -94,21 +98,24 @@ public class TestModularLayer extends AbstractLuceneDistributionTest { + thirdPartyModulesPath.toAbsolutePath()); } - coreModulesFinder = ModuleFinder.of(modulesPath, testModulesPath); - allCoreModules = coreModulesFinder.findAll(); + allLuceneModulesFinder = ModuleFinder.of(modulesPath, testModulesPath); + allLuceneModules = allLuceneModulesFinder.findAll(); + + luceneCoreAndThirdPartyModulesFinder = ModuleFinder.of(modulesPath, thirdPartyModulesPath); } @AfterClass public static void cleanup() { - allCoreModules = null; - coreModulesFinder = null; + allLuceneModules = null; + luceneCoreAndThirdPartyModulesFinder = null; + allLuceneModulesFinder = null; } /** Make sure all published module names remain constant, even if we reorganize the build. */ @Test public void testExpectedDistributionModuleNames() { Assertions.assertThat( - allCoreModules.stream().map(module -> module.descriptor().name()).sorted()) + allLuceneModules.stream().map(module -> module.descriptor().name()).sorted()) .containsExactly( "org.apache.lucene.analysis.common", "org.apache.lucene.analysis.icu", @@ -144,10 +151,42 @@ public class TestModularLayer extends AbstractLuceneDistributionTest { "org.apache.lucene.test_framework"); } + /** Try to instantiate the demo classes so that we make sure their module layer is complete. */ + @Test + public void testDemoClassesCanBeLoaded() { + ModuleLayer bootLayer = ModuleLayer.boot(); + Assertions.assertThatNoException() + .isThrownBy( + () -> { + String demoModuleId = "org.apache.lucene.demo"; + + Configuration configuration = + bootLayer + .configuration() + .resolve( + luceneCoreAndThirdPartyModulesFinder, + ModuleFinder.of(), + List.of(demoModuleId)); + + ModuleLayer layer = + bootLayer.defineModulesWithOneLoader( + configuration, ClassLoader.getSystemClassLoader()); + + for (String className : + List.of( + "org.apache.lucene.demo.IndexFiles", + "org.apache.lucene.demo.SearchFiles", + "org.apache.lucene.index.CheckIndex")) { + Assertions.assertThat(layer.findLoader(demoModuleId).loadClass(className)) + .isNotNull(); + } + }); + } + /** Make sure we don't publish automatic modules. */ @Test public void testAllCoreModulesAreNamedModules() { - Assertions.assertThat(allCoreModules) + Assertions.assertThat(allLuceneModules) .allSatisfy( module -> { Assertions.assertThat(module.descriptor().isAutomatic()) @@ -161,7 +200,7 @@ public class TestModularLayer extends AbstractLuceneDistributionTest { public void testAllModulesHaveExpectedVersion() { String luceneBuildVersion = System.getProperty(VERSION_PROPERTY); Assumptions.assumeThat(luceneBuildVersion).isNotNull(); - for (var module : allCoreModules) { + for (var module : allLuceneModules) { Assertions.assertThat(module.descriptor().rawVersion().orElse(null)) .as("Version of module: " + module.descriptor().name()) .isEqualTo(luceneBuildVersion); @@ -171,7 +210,7 @@ public class TestModularLayer extends AbstractLuceneDistributionTest { /** Ensure SPIs are equal for the module and classpath layer. */ @Test public void testModularAndClasspathProvidersAreConsistent() throws IOException { - for (var module : allCoreModules) { + for (var module : allLuceneModules) { TreeMap> modularProviders = getModularServiceProviders(module); TreeMap> classpathProviders = getClasspathServiceProviders(module); @@ -248,7 +287,7 @@ public class TestModularLayer extends AbstractLuceneDistributionTest { */ @Test public void testAllExportedPackagesInSync() throws IOException { - for (var module : allCoreModules) { + for (var module : allLuceneModules) { Set jarPackages = getJarPackages(module, entry -> true); Set moduleExports = new HashSet<>(module.descriptor().exports()); @@ -295,7 +334,7 @@ public class TestModularLayer extends AbstractLuceneDistributionTest { /** This test ensures that all analysis modules open their resources files to core. */ @Test public void testAllOpenAnalysisPackagesInSync() throws IOException { - for (var module : allCoreModules) { + for (var module : allLuceneModules) { if (false == module.descriptor().name().startsWith("org.apache.lucene.analysis.")) { continue; // at moment we only want to open resources inside analysis packages } diff --git a/lucene/distribution/binary-release.gradle b/lucene/distribution/binary-release.gradle index 04c868e557d..5c03ac3a82a 100644 --- a/lucene/distribution/binary-release.gradle +++ b/lucene/distribution/binary-release.gradle @@ -53,10 +53,12 @@ configure(project(":lucene:distribution")) { transitive = false }) - // The third-party JARs consist of all the transitive dependencies from these modules. - // Not sure whether we have to include all the thirdparty JARs from across all the modules. + // The third-party JARs consist of all the transitive dependencies from a subset of + // all Lucene modules. We only include the demos and Luke. Everything else has to be downloaded + // manually or via maven POMs. for (Project module : [ - project(":lucene:luke") + project(":lucene:luke"), + project(":lucene:demo") ]) { jarsThirdParty(module, { transitive = true