davsclaus opened a new pull request, #29815:
URL: https://github.com/apache/camel/pull/29815

   ## Summary
   
   Item 5 of [CAMEL-26912](https://issues.apache.org/jira/browse/CAMEL-26912): 
**two files with the same name in different directories collapsed into one file 
of the exported project, and one route was silently lost.**
   
   The export copies the route files flat into `src/main/resources/camel` (and 
resources, Kamelets, Java sources and so on into their own directory), by file 
name. `camel export x/route.camel.yaml y/route.camel.yaml` wrote one 
`route.camel.yaml`: the one copied last, and said "Project export successful!".
   
   ### Fix
   
   The export now fails when two different files would be the same file of the 
project, and names them:
   
   ```
   ERROR: Cannot export /work/x/route.camel.yaml and /work/y/route.camel.yaml 
as both would be src/main/resources/camel/route.camel.yaml in the exported 
project: rename one of them
   ```
   
   - Checked where each file is copied (`Exporter.copySourceFiles`): routes, 
resources, Kamelets, JKube fragments, and Java sources (by their package).
   - The same file given twice (such as `x/route.camel.yaml` and 
`x/../x/route.camel.yaml`) is copied once, as before.
   - `ExportException`: the failure of an export that `ProjectExporter` reports 
with its message and exit code 1, without a stack trace (an exception the CLI 
does not know is exit 70 with a stack trace). The export directory is not 
touched: the project is only copied to it at the end.
   
   Keeping both files under their directories (`camel/x/route.camel.yaml`) 
would need the routes include pattern of each runtime (Camel Main, Spring Boot, 
Quarkus) to load subdirectories, so this PR fails clearly instead.
   
   ## Tests
   
   - 
`ProjectExporterTest.failsForTwoFilesWithTheSameNameInDifferentDirectories`: 
exit 1, both paths and the project file in the message, no project written. It 
fails without the check (exit 0).
   - `ProjectExporterTest.copiesTheSameFileGivenTwiceOnce`.
   - camel-jbang-run (272 tests), camel-jbang-core including 
`RunExportGoldenTest` (golden files unchanged), and 
camel-jbang-plugin-kubernetes (156 tests) pass locally.
   - With the unpacked launcher, `camel export x/route.camel.yaml 
y/route.camel.yaml`: the current launcher exits 0 with only `route-y` in the 
project; with the new camel-jbang-run jar it exits 1 with the message above, 
and writes no project.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to