Claus Ibsen created CAMEL-25717:
-----------------------------------

             Summary: camel-jbang - The docs of camel test init list the 
options of camel init
                 Key: CAMEL-25717
                 URL: https://issues.apache.org/jira/browse/CAMEL-25717
             Project: Camel
          Issue Type: Bug
          Components: camel-jbang, tooling
    Affects Versions: 4.23.0
            Reporter: Claus Ibsen
             Fix For: 4.24.0


The generated page of {{camel test init}} 
([camel-jbang-test-init.adoc|https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-test-init.adoc],
 and the {{camel-jbang-plugin-commands-metadata.json}} of 
camel-jbang-plugin-test) lists the options of {{camel init}}: {{--clean-dir}}, 
{{--dir}}, {{--force}}, {{--from-kamelet}}, {{--kamelets-version}}, {{--list}}, 
{{--pipe}} and {{--repo}}. {{camel test init}} has none of them: {{TestInit}} 
extends {{org.citrusframework.jbang.cli.commands.Init}} of Citrus, whose 
options in Citrus 5.0.2 are the {{<file>}} parameter, {{--directory}} (default 
{{.}}) and {{-h,--help}}. The page has been wrong since it was added in 4.23.0 
(https://github.com/apache/camel/pull/27301).

*Cause:* {{PrepareCamelJBangCommandsMojo.parseOptionsFromClassHierarchy}} 
(camel-package-maven-plugin) drops the package of the superclass, and 
{{findClassFile}} looks for its source by simple name. The Citrus {{Init}} is 
not in the source tree, so the fallback for a plugin command that extends a 
command of camel-jbang-core ({{coreCommandsDir}}) finds the {{Init.java}} of 
camel-jbang-core and documents its options. A plugin command whose superclass 
from a library has the simple name of a core command would be documented the 
same way.

*Fix:* only take a source file whose class is the superclass (same package, or 
the qualified name from the imports), for example by comparing the qualified 
name of the parsed class with the super type; otherwise document no inherited 
options, or read them from the class with picocli, as there is no source to 
parse. Then regenerate the page and the metadata.

Found in https://github.com/apache/camel/pull/27995 ({{camel init --force}}), 
where the regenerated page of {{camel test init}} got {{--force}} too.

_Claude Code on behalf of davsclaus_



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

Reply via email to