This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new 3645df35c9d CAMEL-22214: camel-groovy - Make it possible to 
camel-jbang export with pre-compiled groovy classes for camel-main
3645df35c9d is described below

commit 3645df35c9d03a54964b5aefa374ce2906e79334
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jul 18 15:42:53 2025 +0200

    CAMEL-22214: camel-groovy - Make it possible to camel-jbang export with 
pre-compiled groovy classes for camel-main
---
 .../src/main/docs/spring-boot.json                 |  9 ++++++-
 .../boot/FatJarPackageScanResourceResolver.java    | 29 +++++++++++++++-------
 2 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.json 
b/core/camel-spring-boot/src/main/docs/spring-boot.json
index fbc9d7e1b8f..eb032f4e5a8 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.json
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.json
@@ -773,12 +773,19 @@
       "description": "Sets global options that can be referenced in the camel 
context <p\/> <b>Important:<\/b> This has nothing to do with property 
placeholders, and is just a plain set of key\/value pairs which are used to 
configure global options on CamelContext, such as a maximum debug logging 
length etc.",
       "sourceType": 
"org.apache.camel.spring.boot.CamelConfigurationProperties$Main"
     },
+    {
+      "name": "camel.main.groovy-preload-compiled",
+      "type": "java.lang.Boolean",
+      "description": "Whether to preload existing compiled Groovy sources from 
the compileWorkDir option on startup. This can be enabled to avoid compiling 
sources that already has been compiled during a build phase.",
+      "sourceType": 
"org.apache.camel.spring.boot.CamelConfigurationProperties$Main",
+      "defaultValue": false
+    },
     {
       "name": "camel.main.groovy-script-pattern",
       "type": "java.lang.String",
       "description": "Directories to scan for groovy source to be 
pre-compiled. For example: scripts\/*.groovy will scan inside the classpath 
folder scripts for all groovy source files. By default, sources are scanned 
from the classpath, but you can prefix with file: to use file system. The 
directories are using Ant-path style pattern, and multiple directories can be 
specified separated by comma. This requires having camel-groovy JAR on the 
classpath.",
       "sourceType": 
"org.apache.camel.spring.boot.CamelConfigurationProperties$Main",
-      "defaultValue": "classpath:camel-groovy\/*"
+      "defaultValue": 
"classpath:camel-groovy\/*,classpath:camel-groovy-compiled\/*"
     },
     {
       "name": "camel.main.include-non-singletons",
diff --git 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/FatJarPackageScanResourceResolver.java
 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/FatJarPackageScanResourceResolver.java
index 550a6d481a3..d48108f785b 100644
--- 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/FatJarPackageScanResourceResolver.java
+++ 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/FatJarPackageScanResourceResolver.java
@@ -25,6 +25,7 @@ import java.net.URLDecoder;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.function.Predicate;
 import java.util.jar.JarEntry;
 import java.util.jar.JarInputStream;
 
@@ -48,12 +49,12 @@ public class FatJarPackageScanResourceResolver extends 
DefaultPackageScanResourc
     private static final String SPRING_BOOT_WEB_INF_CLASSES_ROOT = 
"WEB-INF/classes/";
 
     @Override
-    protected List<String> doLoadImplementationsInJar(String packageName, 
InputStream stream, String urlPath) {
-        return doLoadImplementationsInJar(packageName, stream, urlPath, true, 
true);
+    protected List<String> doLoadImplementationsInJar(String packageName, 
InputStream stream, String urlPath, Predicate<String> filter) {
+        return doLoadImplementationsInJar(packageName, stream, urlPath, true, 
true, filter);
     }
 
     protected List<String> doLoadImplementationsInJar(String packageName, 
InputStream stream, String urlPath,
-            boolean inspectNestedJars, boolean closeStream) {
+            boolean inspectNestedJars, boolean closeStream, Predicate<String> 
filter) {
         List<String> entries = new ArrayList<>();
 
         JarInputStream jarStream = null;
@@ -67,13 +68,23 @@ public class FatJarPackageScanResourceResolver extends 
DefaultPackageScanResourc
                     String nestedUrl = urlPath + "!/" + name;
                     LOG.trace("Inspecting nested jar: {}", nestedUrl);
                     List<String> nestedEntries = 
doLoadImplementationsInJar(packageName, jarStream, nestedUrl, false,
-                            false);
+                            false, filter);
                     entries.addAll(nestedEntries);
-                } else if (!entry.isDirectory() && !name.endsWith(".class")) {
-                    name = cleanupSpringBootClassName(name);
-                    // name is FQN so it must start with package name
-                    if (name.startsWith(packageName)) {
-                        entries.add(name);
+                } else if (!entry.isDirectory()) {
+                    boolean accept;
+                    if (filter != null) {
+                        // use filter to accept or not
+                        accept = filter.test(name);
+                    } else {
+                        // skip class files by default
+                        accept = !name.endsWith(".class");
+                    }
+                    if (accept) {
+                        name = cleanupSpringBootClassName(name);
+                        // name is FQN so it must start with package name
+                        if (name.startsWith(packageName)) {
+                            entries.add(name);
+                        }
                     }
                 }
             }

Reply via email to