You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Thomas Raddatz (Jira)" <ji...@apache.org> on 2026/10/08 08:08:00 UTC
[jira] [Created] (CAMEL-25452) camel-jbang - camel export ignores --resource-dir, the directories never reach the exported project
Thomas Raddatz created CAMEL-25452:
--------------------------------------
Summary: camel-jbang - camel export ignores --resource-dir, the directories never reach the exported project
Key: CAMEL-25452
URL: https://issues.apache.org/jira/browse/CAMEL-25452
Project: Camel
Issue Type: Bug
Components: camel-jbang
Affects Versions: 4.22.1, 4.22.0
Reporter: Thomas Raddatz
h3. Problem
CAMEL-24226 added {{--resource-dir}} to {{camel run}} and {{camel export}}. {{camel run}} puts the directories on the classpath, but {{camel export}} silently drops them:
* when a route loads such a resource while the export starts the routes to collect their dependencies, the export fails:
{noformat}org.apache.camel.FailedToCreateRouteException: Failed to create route: route1 at: >>> SetBody[simple{resource:classpath:schemas/api.yaml}] <<< ...
Caused by: java.io.FileNotFoundException: Cannot find resource: resource:classpath:schemas/api.yaml for URI: resource:classpath:schemas/api.yaml{noformat}
* otherwise the export succeeds, but {{src/main/resources}} of the exported project contains none of the directories, and no warning is printed.
{{Export}} is only a front: it copies its options field by field onto the runtime-specific command ({{ExportCamelMain}}, {{ExportSpringBoot}}, {{ExportQuarkus}}) in {{Export.export(Path, ExportBaseCommand)}}. {{resourceDirs}} is missing from that list, so {{ExportBaseCommand.copyResourceDirs}} and the {{run.resourceDirs}} handed to the export run of the routes always see an empty list. {{camel kubernetes export}} goes through the same method ({{KubernetesExport}} extends {{Export}}) and is affected the same way.
{{ResourceDirsTest}} covers the helpers ({{validateResourceDir}}, {{walkResourceDir}}) and re-implements the copy loop; no test runs {{camel export}} with the option.
h3. How to reproduce
{code}
mkdir -p demo/schemas && cd demo
echo 'openapi: 3.0.3' > schemas/api.yaml
cat > hello.camel.yaml <<'EOF'
- route:
from:
uri: timer:hello?repeatCount=1
steps:
- setBody:
simple: resource:classpath:schemas/api.yaml
- log: "${body}"
EOF
camel run hello.camel.yaml --resource-dir=schemas --max-messages=1 # logs "openapi: 3.0.3"
camel export hello.camel.yaml --resource-dir=schemas --runtime=quarkus --dir=export
# FailedToCreateRouteException ... Cannot find resource: resource:classpath:schemas/api.yaml
{code}
Reproduced with Camel JBang 4.22.1. A route that does not load the resource at start-up exports, but without {{src/main/resources/schemas}}.
h3. Workaround
Copy the directories into the exported project after the export, e.g. {{cp -r schemas export/src/main/resources/}}.
h3. Proposed fix
Hand the option on in {{Export.export(Path, ExportBaseCommand)}} like every other option: {{cmd.resourceDirs = this.resourceDirs;}}. A parameterized test in {{ExportTest}} runs {{camel export --resource-dir=<relative dir>}} for every runtime and checks that the directory, including a sub-directory, lands under {{src/main/resources/<last path component>}}.
h3. Affected versions
4.22.0 and 4.22.1 (the option exists since 4.22.0). {{main}} is affected as well.
h3. Related
* CAMEL-24226: camel run/export - add --resource-dirs option
--
This message was sent by Atlassian Jira
(v8.20.10#820010)