uschindler commented on code in PR #12188:
URL: https://github.com/apache/lucene/pull/12188#discussion_r1127459715


##########
gradle/generation/panama-foreign.gradle:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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 = file('src/generated/jdk');
+    panamaJavaVersions = [ 19, 20 ]
+  }
+  
+  configurations {
+    apiextractor
+  }
+
+  dependencies {
+    apiextractor "org.ow2.asm:asm:${scriptDepVersions['asm']}"
+  }
+
+  for (jdkVersion : panamaJavaVersions) {
+    def task = tasks.create(name: "generatePanamaForeignApiJar${jdkVersion}", 
type: JavaExec) {
+      description "Regenerate the API-only JAR file with public Panama Foreign 
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 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

Review Comment:
   I added this eplicit to not fail on "regenerate". Actually regenerating is 
not needed, as it will normally produce always the same apijar files, unless 
JDK changes. The regenerate task here is more for "legal" or "update" reasons, 
so anybody can regenerate those apijar files if needed - under normal 
circumstances thats not needed.
   
   This is why I added this check. One reason is also that JDK 20 is not yet 
released, so the autodownloader does not work. We can remove that piece of 
code, but it works and complains loud that it did not do anything.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to