[
https://issues.apache.org/jira/browse/CAMEL-25673?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-25673.
---------------------------------
Resolution: Fixed
> camel-jbang - camel_write_file creates a second copy of a Java class in
> another folder of the project
> -----------------------------------------------------------------------------------------------------
>
> Key: CAMEL-25673
> URL: https://issues.apache.org/jira/browse/CAMEL-25673
> Project: Camel
> Issue Type: Improvement
> Components: camel-jbang
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 4.24.0
>
>
> A model asked to change an existing Java class of a {{camel run}} project
> often writes a new copy of the class in another folder, instead of editing
> the existing file. For example, the project has {{OrderNumber.java}} next to
> its routes (the flat layout of camel run), and the model writes
> {{src/main/java/camel/example/OrderNumber.java}}. The project then has two
> classes {{camel.example.OrderNumber}}. Which one the runtime compiles and
> uses is not what the model expects, and the change it meant to make lands in
> the copy.
> h3. Seen in a local-model benchmark
> qwen3.6 35B-A3B, 10 runs. The step: "move the timer period and the first
> order number to application.properties ... the class gets a setStart(int)".
> It passed 3 of 10 times:
> * 7 of the 11 writes of {{OrderNumber.java}} went to
> {{src/main/java/camel/example/OrderNumber.java}}.
> * {{camel_get_files}} had reported the flat layout and the class at
> {{OrderNumber.java}}.
> * Every one of the 11 writes had the right change. Only the place was wrong.
> h3. Proposal
> * When {{camel_write_file}} creates a new Java source whose class (package
> and name) another file of the project already defines, refuse with an answer
> that names the existing file. For example: "camel.example.OrderNumber is
> already in OrderNumber.java: change that file with camel_edit_file, or remove
> it first if you mean to move the class".
> * Optionally, a warning when a new file has the name of an existing
> configuration file in another folder (a second {{beans.yaml}} or
> {{application.properties}} under {{src/main/resources}}): camel run loads
> both, which is just as surprising.
> Code: {{camel_write_file}} in
> {{dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/AuthoringTools.java}}.
> Related: CAMEL-24798 ({{camel_get_files}} understands the Maven layout).
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)