davsclaus opened a new pull request, #28675: URL: https://github.com/apache/camel/pull/28675
## Description [CAMEL-24727](https://issues.apache.org/jira/browse/CAMEL-24727) (stage 1 of [CAMEL-24724](https://issues.apache.org/jira/browse/CAMEL-24724)), part 2 **Stacked on #28671**, which adds the `camel-jbang-export` module and moves the helpers into it. Review that PR first. This PR targets its branch and will be retargeted to `main` once #28671 is merged. This PR moves the logic of `camel export` into `camel-jbang-export` as a Java API, so a tool such as Kaoto can export a project without running the `camel` command: ```java ExportRequest request = new ExportRequest(); request.files.add("hello.camel.yaml"); request.runtime = RuntimeType.main; request.exportDir = "target/hello"; int exit = new ProjectExporter().export(request); ``` **The API (`org.apache.camel.dsl.jbang.export`, no picocli or jline)** - `ExportRequest`: the options of `camel export` as public fields, with a shallow copy constructor. - `ProjectExporter`: `prepare(request)` reads `application.properties`, the profile and the system properties into the request, the same as `camel export`. `export(request)` prepares the request, gives it a GAV and exports it. - `Exporter` (was `ExportBaseCommand`) and `CamelMainExporter`, `QuarkusExporter`, `SpringBootExporter` (were `ExportCamelMain`, `ExportQuarkus`, `ExportSpringBoot`): moved with `git mv`, so the history follows. Each export works on a copy of the request. - `ExportContext`: sets where the export prints, how it asks for confirmation (before it cleans the export directory), the exporters of the plugins, and the `DependencyResolver`. - `MavenResolver` and `QuarkusPlatform`: the options of the two mixins without picocli. The mixins now delegate to them. **The silent run behind an SPI** To find the dependencies, the export boots the integration silently, using the same pipeline in `Run.run()` as a plain `camel run`. This PR leaves that pipeline untouched and puts it behind the `DependencyResolver` SPI. camel-jbang-core implements it (`RunDependencyResolver`) and registers it with the `ServiceLoader`. Until a follow-up provides an implementation without picocli, a consumer of the API needs camel-jbang-core on the runtime classpath, or must set its own resolver on the `ExportContext`. **In camel-jbang-core** - `ExportBaseCommand` keeps the picocli options and builds the request (`toRequest`). After `prepare`, it takes back the options that `application.properties` and the profile set (`fromRequest`), because subclasses read them. - `camel export`, `camel dependency list`, `camel sbom`, `camel kubernetes export` and `camel run --runtime=main|quarkus|spring-boot` use the API. No CLI option is added, removed or renamed. - `KubernetesExport` sets its pom template through a `customizeRequest` hook. - `camel kubernetes run` sets `symbolicLink` and `javaLiveReload`, but the export never passed them on. This PR keeps that behaviour; [CAMEL-26403](https://issues.apache.org/jira/browse/CAMEL-26403) tracks it. **Resources** - The templates of the exported project move to camel-jbang-export: the pom, Dockerfile, readme, AGENTS.md and main-class templates. - So do the Maven and Camel wrappers, `quarkus-docker`, `quarkus-dependencies.properties` and `log4j2-main.properties`. - The `log4j2.component.properties` of exported projects is read from `export/` in the jar, so log4j2 does not load it in the JVM of a tool that uses the API. - The templates that `camel init` and `camel run` use stay in camel-jbang-core. **Docs** - A new section, "Exporting from Java", on the export page of the manual. **Tests** - `ProjectExporterTest` (new) exports a Camel Main project in camel-jbang-export, with a stub resolver and without camel-jbang-core. - The tests of exporter internals move to camel-jbang-export: `ExporterCopySourceFilesTest`, `QuarkusExporterTest`, `SpringBootExporterTest` and `ExporterTest`. - I ran the tests of every module this PR touches, and they pass: - export 104, core 2,657, TUI 2,283, MCP 505, kubernetes 156, launcher 292 (36 skipped), validate 23, and the generate and test plugins. - One exception in core: `EvalSimpleTest` (a local-only test, skipped on CI) failed. It fails the same way on the #28671 branch, since it starts the Camel that is installed with JBang on the machine, not the code of the PR. - The regenerated command metadata is unchanged. _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
