/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // Produce an MR-JAR with Java 19+ MemorySegment implementation for MMapDirectory configure(project(":lucene:core")) { plugins.withType(JavaPlugin) { for (jdkVersion : panamaJavaVersions) { sourceSets.create("main${jdkVersion}") { java { srcDirs = ["src/java${jdkVersion}"] } } configurations["main${jdkVersion}Implementation"].extendsFrom(configurations['implementation']) dependencies.add("main${jdkVersion}Implementation", sourceSets.main.output) tasks.named("compileMain${jdkVersion}Java").configure { def apijar = new File(apijars, "panama-foreign-jdk${jdkVersion}.apijar") inputs.file(apijar) int releaseIndex = options.compilerArgs.indexOf("--release") options.compilerArgs.removeAt(releaseIndex) options.compilerArgs.removeAt(releaseIndex) options.compilerArgs += [ "-Xlint:-options", "--patch-module", "java.base=${apijar}", "--add-exports", "java.base/java.lang.foreign=ALL-UNNAMED", ] } } tasks.named('jar').configure { for (jdkVersion : panamaJavaVersions) { into("META-INF/versions/${jdkVersion}") { from sourceSets["main${jdkVersion}"].output } } manifest.attributes( 'Multi-Release': 'true' ) } } }