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 d347f70da06 CAMEL-23169: camel-jbang - Export to standalone should 
package fat-jar using camel-repacker-plugin which we use in camel-launcher and 
spring boot as well.
d347f70da06 is described below

commit d347f70da06b90a7284e6004cc5bb20a99a89ce0
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Mar 11 12:31:16 2026 +0100

    CAMEL-23169: camel-jbang - Export to standalone should package fat-jar 
using camel-repacker-plugin which we use in camel-launcher and spring boot as 
well.
---
 .../camel/spring/boot/CamelAutoConfiguration.java  |   2 +
 .../boot/FatJarPackageScanClassResolver.java       | 134 -------------------
 .../boot/FatJarPackageScanResourceResolver.java    | 147 ---------------------
 3 files changed, 2 insertions(+), 281 deletions(-)

diff --git 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
index d904ddf8809..338a70e2bc2 100644
--- 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
+++ 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
@@ -38,6 +38,8 @@ import org.apache.camel.main.DebuggerConfigurationProperties;
 import org.apache.camel.main.DefaultConfigurationConfigurer;
 import org.apache.camel.main.MainListener;
 import org.apache.camel.main.RoutesCollector;
+import org.apache.camel.main.fatjar.FatJarPackageScanClassResolver;
+import org.apache.camel.main.fatjar.FatJarPackageScanResourceResolver;
 import org.apache.camel.model.Model;
 import org.apache.camel.spi.BeanRepository;
 import org.apache.camel.spi.CliConnector;
diff --git 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/FatJarPackageScanClassResolver.java
 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/FatJarPackageScanClassResolver.java
deleted file mode 100644
index 52b2eaba82d..00000000000
--- 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/FatJarPackageScanClassResolver.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * 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.
- */
-package org.apache.camel.spring.boot;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-
-import org.apache.camel.support.scan.DefaultPackageScanClassResolver;
-import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.StringHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * An implementation of the {@code 
org.apache.camel.spi.PackageScanClassResolver} that is able to scan spring-boot 
fat
- * jars to find classes contained also in nested jars.
- */
-public class FatJarPackageScanClassResolver extends 
DefaultPackageScanClassResolver {
-    private static final Logger LOG = 
LoggerFactory.getLogger(FatJarPackageScanClassResolver.class);
-
-    private static final String SPRING_BOOT_CLASSIC_LIB_ROOT = "lib/";
-    private static final String SPRING_BOOT_BOOT_INF_LIB_ROOT = 
"BOOT-INF/lib/";
-    private static final String SPRING_BOOT_BOOT_INF_CLASSES_ROOT = 
"BOOT-INF/classes/";
-    private static final String SPRING_BOOT_WEB_INF_LIB_ROOT = "WEB-INF/lib/";
-    private static final String SPRING_BOOT_WEB_INF_CLASSES_ROOT = 
"WEB-INF/classes/";
-
-    @Override
-    protected List<String> doLoadJarClassEntries(InputStream stream, String 
urlPath) {
-        return doLoadJarClassEntries(stream, urlPath, true, true);
-    }
-
-    @Override
-    protected String parseUrlPath(URL url) {
-        String urlPath = url.getFile();
-
-        urlPath = URLDecoder.decode(urlPath, StandardCharsets.UTF_8);
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("Decoded urlPath: {} with protocol: {}", urlPath, 
url.getProtocol());
-        }
-
-        String nested = "nested:";
-        if (urlPath.startsWith(nested)) {
-            try {
-                urlPath = (new URI(url.getFile())).getPath();
-                return StringHelper.before(urlPath, "!", urlPath);
-            } catch (URISyntaxException e) {
-                // ignore
-            }
-            if (urlPath.startsWith(nested)) {
-                urlPath = urlPath.substring(nested.length());
-                return StringHelper.before(urlPath, "!", urlPath);
-            }
-        }
-
-        return super.parseUrlPath(url);
-    }
-
-    protected List<String> doLoadJarClassEntries(InputStream stream, String 
urlPath, boolean inspectNestedJars,
-            boolean closeStream) {
-        List<String> entries = new ArrayList<>();
-
-        JarInputStream jarStream = null;
-        try {
-            jarStream = new JarInputStream(stream);
-
-            JarEntry entry;
-            while ((entry = jarStream.getNextJarEntry()) != null) {
-                String name = entry.getName();
-
-                name = name.trim();
-                if (!entry.isDirectory() && name.endsWith(".class")) {
-                    entries.add(cleanupSpringBootClassName(name));
-                } else if (inspectNestedJars && !entry.isDirectory() && 
isSpringBootNestedJar(name)) {
-                    String nestedUrl = urlPath + "!/" + name;
-                    LOG.trace("Inspecting nested jar: {}", nestedUrl);
-
-                    List<String> nestedEntries = 
doLoadJarClassEntries(jarStream, nestedUrl, false, false);
-                    entries.addAll(nestedEntries);
-                }
-            }
-        } catch (IOException ioe) {
-            LOG.warn("Cannot search jar file '" + urlPath + " due to an 
IOException: " + ioe.getMessage()
-                    + ". This exception is ignored.", ioe);
-        } finally {
-            if (closeStream) {
-                // stream is left open when scanning nested jars, otherwise 
the fat jar stream gets closed
-                IOHelper.close(jarStream, urlPath, LOG);
-            }
-        }
-
-        return entries;
-    }
-
-    private boolean isSpringBootNestedJar(String name) {
-        // Supporting both versions of the packaging model
-        return name.endsWith(".jar") && 
(name.startsWith(SPRING_BOOT_CLASSIC_LIB_ROOT)
-                || name.startsWith(SPRING_BOOT_BOOT_INF_LIB_ROOT) || 
name.startsWith(SPRING_BOOT_WEB_INF_LIB_ROOT));
-    }
-
-    private String cleanupSpringBootClassName(String name) {
-        // Classes inside BOOT-INF/classes will be loaded by the new 
classloader as if they were in the root
-        if (name.startsWith(SPRING_BOOT_BOOT_INF_CLASSES_ROOT)) {
-            name = name.substring(SPRING_BOOT_BOOT_INF_CLASSES_ROOT.length());
-        }
-        if (name.startsWith(SPRING_BOOT_WEB_INF_CLASSES_ROOT)) {
-            name = name.substring(SPRING_BOOT_WEB_INF_CLASSES_ROOT.length());
-        }
-        return name;
-    }
-
-}
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
deleted file mode 100644
index d48108f785b..00000000000
--- 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/FatJarPackageScanResourceResolver.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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.
- */
-package org.apache.camel.spring.boot;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-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;
-
-import org.apache.camel.support.scan.DefaultPackageScanResourceResolver;
-import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.StringHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * An implementation of the {@code 
org.apache.camel.spi.PackageScanResourceResolver} that is able to scan 
spring-boot
- * fat jars to find resources contained also in nested jars.
- */
-public class FatJarPackageScanResourceResolver extends 
DefaultPackageScanResourceResolver {
-    private static final Logger LOG = 
LoggerFactory.getLogger(FatJarPackageScanResourceResolver.class);
-
-    private static final String SPRING_BOOT_CLASSIC_LIB_ROOT = "lib/";
-    private static final String SPRING_BOOT_BOOT_INF_LIB_ROOT = 
"BOOT-INF/lib/";
-    private static final String SPRING_BOOT_BOOT_INF_CLASSES_ROOT = 
"BOOT-INF/classes/";
-    private static final String SPRING_BOOT_WEB_INF_LIB_ROOT = "WEB-INF/lib/";
-    private static final String SPRING_BOOT_WEB_INF_CLASSES_ROOT = 
"WEB-INF/classes/";
-
-    @Override
-    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, Predicate<String> 
filter) {
-        List<String> entries = new ArrayList<>();
-
-        JarInputStream jarStream = null;
-        try {
-            jarStream = new JarInputStream(stream);
-
-            JarEntry entry;
-            while ((entry = jarStream.getNextJarEntry()) != null) {
-                String name = entry.getName().trim();
-                if (inspectNestedJars && !entry.isDirectory() && 
isSpringBootNestedJar(name)) {
-                    String nestedUrl = urlPath + "!/" + name;
-                    LOG.trace("Inspecting nested jar: {}", nestedUrl);
-                    List<String> nestedEntries = 
doLoadImplementationsInJar(packageName, jarStream, nestedUrl, false,
-                            false, filter);
-                    entries.addAll(nestedEntries);
-                } 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);
-                        }
-                    }
-                }
-            }
-        } catch (IOException ioe) {
-            LOG.warn("Cannot search jar file '" + urlPath + " due to an 
IOException: " + ioe.getMessage()
-                    + ". This exception is ignored.", ioe);
-        } finally {
-            if (closeStream) {
-                // stream is left open when scanning nested jars, otherwise 
the fat jar stream gets closed
-                IOHelper.close(jarStream, urlPath, LOG);
-            }
-        }
-
-        return entries;
-    }
-
-    @Override
-    protected String parseUrlPath(URL url) {
-        String urlPath = url.getFile();
-
-        urlPath = URLDecoder.decode(urlPath, StandardCharsets.UTF_8);
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("Decoded urlPath: {} with protocol: {}", urlPath, 
url.getProtocol());
-        }
-
-        String nested = "nested:";
-        if (urlPath.startsWith(nested)) {
-            try {
-                urlPath = (new URI(url.getFile())).getPath();
-                return StringHelper.before(urlPath, "!", urlPath);
-            } catch (URISyntaxException e) {
-                // ignore
-            }
-            if (urlPath.startsWith(nested)) {
-                urlPath = urlPath.substring(nested.length());
-                return StringHelper.before(urlPath, "!", urlPath);
-            }
-        }
-
-        return super.parseUrlPath(url);
-    }
-
-    private boolean isSpringBootNestedJar(String name) {
-        // Supporting both versions of the packaging model
-        return name.endsWith(".jar") && 
(name.startsWith(SPRING_BOOT_CLASSIC_LIB_ROOT)
-                || name.startsWith(SPRING_BOOT_BOOT_INF_LIB_ROOT) || 
name.startsWith(SPRING_BOOT_WEB_INF_LIB_ROOT));
-    }
-
-    private String cleanupSpringBootClassName(String name) {
-        // Classes inside BOOT-INF/classes will be loaded by the new 
classloader as if they were in the root
-        if (name.startsWith(SPRING_BOOT_BOOT_INF_CLASSES_ROOT)) {
-            name = name.substring(SPRING_BOOT_BOOT_INF_CLASSES_ROOT.length());
-        }
-        if (name.startsWith(SPRING_BOOT_WEB_INF_CLASSES_ROOT)) {
-            name = name.substring(SPRING_BOOT_WEB_INF_CLASSES_ROOT.length());
-        }
-        return name;
-    }
-
-}

Reply via email to