[ 
https://issues.apache.org/jira/browse/CAMEL-24226?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen updated CAMEL-24226:
--------------------------------
    Fix Version/s: 4.22.0

> camel export - support --resource-dirs to copy directories into 
> src/main/resources preserving structure
> -------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-24226
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24226
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-jbang
>            Reporter: Claus Ibsen
>            Priority: Major
>             Fix For: 4.22.0
>
>
> When performing a camel export, non-route files (like .xsd, .wsdl) are copied 
> flat into src/main/resources, losing their directory structure.
> For example, if you have:
> {code}
> ./soap/file.xsd
> {code}
> It currently becomes:
> {code}
> src/main/resources/file.xsd
> {code}
> But the expected behavior would be:
> {code}
> src/main/resources/soap/file.xsd
> {code}
> This is a problem for SOAP/WSDL projects where schema files have relative 
> imports between them that depend on directory structure.
> h3. Proposed Feature
> Add a {{--resource-dirs}} option (multi-valued, comma-separated) to {{camel 
> export}} that accepts one or more directories to recursively copy into 
> {{src/main/resources}} while preserving the directory structure.
> The option follows the existing picocli pattern used by {{--dep}} / 
> {{--dependency}}: comma-separated values or repeated option.
> Examples:
> {code}
> camel export --resource-dirs=soap,wsdl
> camel export --resource-dirs=soap --resource-dirs=wsdl
> {code}
> Would produce:
> {code}
> src/main/resources/soap/file.xsd
> src/main/resources/wsdl/service.wsdl
> {code}
> h3. Recursive: Subdirectories Are Included
> The copy is recursive — the entire directory tree is preserved. For example:
> {code}
> soap/
>   schemas/
>     common.xsd
>   file.xsd
> {code}
> With {{--resource-dirs=soap}} produces:
> {code}
> src/main/resources/soap/schemas/common.xsd
> src/main/resources/soap/file.xsd
> {code}
> This is important because schema files (XSD, WSDL) often use relative imports 
> that reference files in subdirectories, so the structure must be preserved.
> h3. Safety: Validate Input Paths
> Since {{Files.walk}} is used for recursive copying, the implementation must 
> guard against dangerous inputs like {{--resource-dirs=/}} which would attempt 
> to traverse the entire filesystem.
> Suggested safeguards:
> * Reject absolute paths — only allow relative paths within or near the 
> project directory
> * At minimum, reject filesystem root paths ({{/}}, {{C:\}})
> * Consider capping the directory depth or total file count as an additional 
> safety net
> h3. Open Question: Relative Paths Outside Project Root
> For paths that go outside the project root (e.g., 
> {{--resource-dirs=../../mydata/foo}}), it is unclear what the target 
> directory structure should be. A simple rule could be: use only the final 
> directory name, so {{../../mydata/foo/}} copies into 
> {{src/main/resources/foo/}}. But this needs further consideration.
> h3. Technical Notes
> The current implementation:
> * {{Run.java}} classifies non-route files as classpath files 
> ({{camel.jbang.classpathFiles}})
> * {{ExportBaseCommand.copySourceFiles()}} copies them flat using only the 
> filename
> * {{RunHelper.dirToFiles()}} only lists immediate children (non-recursive)
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to