Ricardo Martinez created CAMEL-24726:
----------------------------------------

             Summary: camel-jbang: extract camel-jbang-runner module
                 Key: CAMEL-24726
                 URL: https://issues.apache.org/jira/browse/CAMEL-24726
             Project: Camel
          Issue Type: Sub-task
          Components: camel-jbang
            Reporter: Ricardo Martinez


h2. Motivation

{{Run.runCamelMain()}}, {{runQuarkus()}} and {{runSpringBoot()}} (~700 lines) 
contain the logic for exporting a project to a temp dir, packaging it with 
Maven, and launching the resulting JAR or dev server. This logic is reusable 
but today is locked inside the CLI.

Extracting it is the first step toward letting the Camel TUI, Kaoto and 
external tooling build and launch projects through a Java API without spawning 
the {{camel}} binary.

h2. What changes

New module {{dsl/camel-jbang/camel-jbang-runner}} (package 
{{org.apache.camel.dsl.jbang.runner}}).

Dependencies: {{camel-jbang-core}}, {{camel-util}}. No picocli, no jline, no 
camel-kamelet-main.

New public API:

* {{LaunchOptions}} — plain POJO: jvmArgs, jvmDebugPort, profile, dev, 
sourceDir, logFile,
  durationMax*, jfr, quiet
* {{LaunchCommand}} — record(List<String> command, Path workingDir, 
Map<String,String> env) with a {{start()}} convenience method
* {{ProjectRunner}} — interface with {{buildCommand(Path, LaunchOptions)}} 
(runs mvnw package) and {{runCommand(Path, LaunchOptions)}} (runs java -jar / 
quarkus:run / spring-boot:run); implementations: {{CamelMainProjectRunner}}, 
{{QuarkusProjectRunner}}, {{SpringBootProjectRunner}}

{{Run.runCamelMain()}}, {{runQuarkus()}} and {{runSpringBoot()}} in 
{{camel-jbang-core}} each shrink to ~10 lines delegating to the matching 
{{ProjectRunner}}. The exportRun / KameletMain / writeSettings machinery is 
completely untouched.

Add the module to {{dsl/camel-jbang/pom.xml}} and {{bom/camel-bom}}.

h2. Compatibility

* No type moves. No import rewrites anywhere.
* No CLI option added, removed or renamed.
* {{camel run --runtime=main|quarkus|spring-boot}} behaviour is identical.

h2. Note

After this stage a consumer of {{camel-jbang-runner}} still gets picocli, jline 
and camel-kamelet-main transitively through {{camel-jbang-core}}. The 
picocli-free API is available after stage 2.



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

Reply via email to