diff --git a/gradle/java/core-mrjar.gradle b/gradle/java/core-mrjar.gradle index 40ba769c9692..0870ebdbcad3 100644 --- a/gradle/java/core-mrjar.gradle +++ b/gradle/java/core-mrjar.gradle @@ -46,15 +46,22 @@ configure(project(":lucene:core")) { } tasks.named('jar').configure { + boolean needMRJAR = false; mrjarJavaVersions.each { jdkVersion -> - into("META-INF/versions/${jdkVersion}") { + // the sourceSet which corresponds to the mininum/base Java version + // will copy its output to root of JAR, all other sourceSets will go into MR-JAR folders: + boolean isBaseVersion = (jdkVersion.toString() == rootProject.minJavaVersion.toString()) + into(isBaseVersion ? '' : "META-INF/versions/${jdkVersion}") { from sourceSets["main${jdkVersion}"].output } + needMRJAR |= !isBaseVersion } - manifest.attributes( - 'Multi-Release': 'true' - ) + if (needMRJAR) { + manifest.attributes( + 'Multi-Release': 'true' + ) + } } } } diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 9a4883b10533..b1061599876d 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -84,8 +84,8 @@ API Changes make compile() only return the FSTMetadata. For on-heap (default) use case, please use FST.fromFSTReader(fstMetadata, fstCompiler.getFSTReader()) to create the FST. (Anh Dung Bui) -* GITHUB#13146: Remove ByteBufferIndexInput and only use MemorySegment APIs for MMapDirectory. - (Uwe Schindler) +* GITHUB#13146, GITHUB#13148: Remove ByteBufferIndexInput and only use MemorySegment APIs + for MMapDirectory. (Uwe Schindler) New Features --------------------- 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 084a044092f6..84d5df2256aa 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 @@ -207,16 +207,25 @@ public void testMultiReleaseJar() { ClassLoader loader = layer.findLoader(coreModuleId); - final Set jarVersions = Set.of(21); - for (var v : jarVersions) { - Assertions.assertThat( - loader.getResource( - "META-INF/versions/" - + v - + "/org/apache/lucene/store/MemorySegmentIndexInput.class")) - .isNotNull(); - } - + final Set mrJarVersions = Set.of(21); + final Integer baseVersion = 21; + + // the Java 21 PanamaVectorizationProvider must always be in main section of JAR file: + final String panamaClassName = + "org/apache/lucene/internal/vectorization/PanamaVectorizationProvider.class"; + Assertions.assertThat(loader.getResource(panamaClassName)).isNotNull(); + + // additional versions must be in MR-JAR part + mrJarVersions.stream() + .filter(Predicate.not(baseVersion::equals)) + .forEach( + v -> { + Assertions.assertThat( + loader.getResource("META-INF/versions/" + v + panamaClassName)) + .isNotNull(); + }); + + // you must be always able to load MemorySegmentIndexInput: Assertions.assertThat( loader.loadClass("org.apache.lucene.store.MemorySegmentIndexInput")) .isNotNull();