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

   [CAMEL-25717](https://issues.apache.org/jira/browse/CAMEL-25717): **the 
generated page of `camel test init` lists its own options, not those of `camel 
init`.**
   
   ### The problem
   Since it was added in 4.23.0 (#27301), the page of `camel test init` listed 
eight options of `camel init` that it does not have: `--clean-dir`, `--dir`, 
`--force`, `--from-kamelet`, `--kamelets-version`, `--list`, `--pipe` and 
`--repo`. `TestInit` extends the `Init` of Citrus, whose options are 
`--directory` and `-h,--help`.
   
   ### Cause
   `PrepareCamelJBangCommandsMojo` finds the source of a parent class (and of a 
mixin type) by its simple name. The `Init` of Citrus has no source here, so the 
fallback for a plugin command that extends a command of camel-jbang-core found 
the `Init.java` of camel-jbang-core.
   
   ### The change
   - A type that the class imports by name is only taken from a source of that 
type (the same qualified name). Otherwise its options are read from the 
classpath of the project, which the mojo resolves already: the `@Option` fields 
of the class, of its parent classes and of its mixins, by reflection, as 
picocli is not a dependency of the plugin.
   - A type that is not imported by name (the same package) is looked up as 
before, as the package that Roaster resolves for it is not certain: with 
`import static ...CamelJBangConstants.*` (as in `ExportBaseCommand` and 
`DependencyList`), Roaster resolves `CamelCommand` as 
`CamelJBangConstants.CamelCommand`. A first, stricter version of this fix took 
that for a library class, and `camel export` lost its options.
   - Regenerated: the page and the metadata of `camel test init` now have 
`--directory` (default `.`) and `-h,--help`. The generator was run in all 8 
camel-jbang modules that use it, and nothing else changed.
   
   ### Tests
   `PrepareCamelJBangCommandsMojoTest`:
   - a plugin command whose parent `Init` is of a library does not get the 
options of the `Init` of camel-jbang-core;
   - with the library compiled into the classes of the project (with a minimal 
picocli `Option` and `Mixin`), it gets the options of the library class and of 
its parent class;
   - a parent class of the same package is found when the class has a static 
import on demand.
   
   The first two fail without the fix (they get `--from-kamelet`), and the 
third fails with the stricter first version. `mvn test` of 
camel-package-maven-plugin: all pass (85).
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01DDRLJAyf8cDXSg8iX785My
   


-- 
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