2022-12-26 04:07:44 -05:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2023-05-25 02:59:50 -04:00
|
|
|
// Produce an MR-JAR with Java 19+ foreign and vector implementations
|
2022-12-26 04:07:44 -05:00
|
|
|
|
|
|
|
configure(project(":lucene:core")) {
|
|
|
|
plugins.withType(JavaPlugin) {
|
2023-10-12 07:22:48 -04:00
|
|
|
mrjarJavaVersions.each { jdkVersion ->
|
2023-03-09 15:27:31 -05:00
|
|
|
sourceSets.create("main${jdkVersion}") {
|
2022-12-26 04:07:44 -05:00
|
|
|
java {
|
2023-03-09 15:27:31 -05:00
|
|
|
srcDirs = ["src/java${jdkVersion}"]
|
2022-12-26 04:07:44 -05:00
|
|
|
}
|
|
|
|
}
|
2023-03-09 15:27:31 -05:00
|
|
|
configurations["main${jdkVersion}Implementation"].extendsFrom(configurations['implementation'])
|
|
|
|
dependencies.add("main${jdkVersion}Implementation", sourceSets.main.output)
|
2022-12-26 04:07:44 -05:00
|
|
|
|
2023-03-09 15:27:31 -05:00
|
|
|
tasks.named("compileMain${jdkVersion}Java").configure {
|
2023-09-21 04:42:20 -04:00
|
|
|
def apijar = apijars.file("jdk${jdkVersion}.apijar")
|
2023-03-09 15:27:31 -05:00
|
|
|
|
|
|
|
int releaseIndex = options.compilerArgs.indexOf("--release")
|
|
|
|
options.compilerArgs.removeAt(releaseIndex)
|
|
|
|
options.compilerArgs.removeAt(releaseIndex)
|
|
|
|
options.compilerArgs += [
|
|
|
|
"-Xlint:-options",
|
|
|
|
"--add-exports", "java.base/java.lang.foreign=ALL-UNNAMED",
|
2023-05-25 02:59:50 -04:00
|
|
|
// for compilation we patch the incubator packages into java.base, this has no effect on resulting class files:
|
|
|
|
"--add-exports", "java.base/jdk.incubator.vector=ALL-UNNAMED",
|
2023-03-09 15:27:31 -05:00
|
|
|
]
|
2023-09-21 04:42:20 -04:00
|
|
|
|
|
|
|
options.compilerArgumentProviders.add(new CompilerArgsProvider(apiJarFile: apijar))
|
2022-12-26 04:07:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.named('jar').configure {
|
2023-10-12 07:22:48 -04:00
|
|
|
mrjarJavaVersions.each { jdkVersion ->
|
2023-03-09 15:27:31 -05:00
|
|
|
into("META-INF/versions/${jdkVersion}") {
|
|
|
|
from sourceSets["main${jdkVersion}"].output
|
|
|
|
}
|
2022-12-26 04:07:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
manifest.attributes(
|
|
|
|
'Multi-Release': 'true'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-09-21 04:42:20 -04:00
|
|
|
|
|
|
|
class CompilerArgsProvider implements CommandLineArgumentProvider {
|
|
|
|
|
|
|
|
@InputFile
|
|
|
|
@PathSensitive(PathSensitivity.RELATIVE)
|
|
|
|
RegularFile apiJarFile
|
|
|
|
|
|
|
|
@Override
|
|
|
|
Iterable<String> asArguments() {
|
|
|
|
return ["--patch-module", "java.base=${apiJarFile}"]
|
|
|
|
}
|
|
|
|
}
|