lucene/gradle/generation/extract-jdk-apis.gradle
Dawid Weiss 1cfa697c06
Fix eclipse ide settings generation (#13649)
* Only run the ide configuration block for eclipse when explicitly invoked. fix property access ordering here and there.

* Correct dependsOn task name.

* Correct crlf/encoding after versionCatalogFormatDeps finishes.

* Change java-library to java-base in the plugin applied within the eclipse task.

* use ant.fixcrlf to correct line endings.

* Changes entry.

* Simplify fixcrlf

---------

Co-authored-by: Uwe Schindler <uschindler@apache.org>
2024-08-14 23:50:06 +02:00

72 lines
2.4 KiB
Groovy

/*
* 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.
*/
def resources = scriptResources(buildscript)
configure(project(":lucene:core")) {
ext {
apijars = layout.projectDirectory.dir("src/generated/jdk")
mrjarJavaVersions = [ 21 ]
}
configurations {
apiextractor
}
dependencies {
apiextractor deps.asm.core
}
plugins.withType(JavaPlugin) {
mrjarJavaVersions.each { jdkVersion ->
def task = tasks.create(name: "generateJdkApiJar${jdkVersion}", type: JavaExec) {
description "Regenerate the API-only JAR file with public Panama Foreign & Vector API from JDK ${jdkVersion}"
group "generation"
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(jdkVersion)
}
onlyIf {
try {
javaLauncher.get()
return true
} catch (Exception e) {
logger.warn('Launcher for Java {} is not available; skipping regeneration of Panama Foreign & Vector API JAR.', jdkVersion)
logger.warn('Error: {}', e.cause?.message)
logger.warn("Please make sure to point env 'JAVA{}_HOME' to exactly JDK version {} or enable Gradle toolchain auto-download.", jdkVersion, jdkVersion)
return false
}
}
classpath = configurations.apiextractor
mainClass = file("${resources}/ExtractJdkApis.java") as String
systemProperties = [
'user.timezone': 'UTC',
'file.encoding': 'UTF-8',
]
args = [
jdkVersion,
apijars.file("jdk${jdkVersion}.apijar"),
]
}
regenerate.dependsOn task
}
}
}