davsclaus opened a new pull request, #28743: URL: https://github.com/apache/camel/pull/28743
_Claude Code on behalf of davsclaus_ Stage 2d of [CAMEL-24726](https://issues.apache.org/jira/browse/CAMEL-24726), after #28741 (2c), which made `ProjectRunner` run every Maven runtime. `ProjectRunner` now also runs the jbang runtime, in the current JVM, as `camel run` does. There is one sequence of that run, in the engine: `camel run` calls it, and hooks in what only the CLI does through the `RunContext`. `Run` is mostly the mapping of the picocli options onto a `RunRequest` now. ## Changes - **The run in the current JVM** (`JBangRunner` and `KameletMainIntegration`, package-private): prepare the work directory, load the application properties, generate the OpenAPI routes, find the files (with the "Cannot run because application.properties file does not exist ..." message), drop duplicate files, configure the pipeline (with the plugins), then start Camel, with the "No routes found" check, the JFR recording, the log of the previous run (CAMEL-25784), the exit code, and `ignoreLoadingError`. - **A configure step.** `ProjectRunner.configure(RunRequest)` returns a `ConfiguredRun` (the configured `KameletMain`, the request, and the exit code when it cannot run); `ConfiguredRun.start()` starts it. `camel run` decides after configuring whether the integration runs in this JVM or the camel CLI is started again in another one (`--background`, `--camel-version`, `camel debug`), as before. `ProjectRunner.start(request)` is configure + start. - **The handle of a run in this JVM**: `start()` starts Camel; `waitFor()` runs it in the calling thread until it stops, as `camel run` in the foreground; `stop()` stops it; `pid()` is the one of this JVM. `RunningIntegration.waitFor()` throws `Exception` now, so the error of a route that fails to start reaches the caller as it is. - **What the CLI hooks in through `RunContext`**: - `withPreparedListener`: called once the application properties are loaded, before anything is printed or logged, with the properties and whether MCP runs over stdio. `camel run` configures the logging there (the engine configures none), and writes the `--code` file, as the first file, in the work directory that the engine has just prepared. - `withReloadFailureListener`: a route file that fails to reload in dev mode, as `withStartFailureListener` is for a failed start. `camel run` sets both to the YAML report of `camel validate yaml` (CAMEL-24851), so a Java API run gets the same hooks. - `withInitialProperties`, `withClipboard`, `withDataDirWithoutSourceDir`: the hooks of `Run` that other commands use (`camel debug`, `camel transform`, `camel cmd send --local`, ...). - `withFailureExitCode`: the exit code of a run whose start failed (default 1); `camel run` maps it as for any command (70 for a route that fails to start), and the log of the previous run records it. - **The plugins are found once.** `ExportContext.withPlugins(Function<String, ActivePlugins>)` gives the run customizers and the exporters of the active plugins in one call, and replaces `withPluginExporters` and `withPluginRunCustomizers`. The run, the silent run of an export and the exporter use it; `Run` has no plugin code of its own any more. - **What the CLI asked from `Run` itself is now explicit in the request**: `RunRequest.logFile` and `keepPreviousLog` (`camel run` on the command line keeps the log of the previous run; `camel transform` and `camel cmd send --local` do not). - **Detection shared by every runtime**: a directory as the file to run (`camel run .`) and the runtime of a `pom.xml` (`RunPipeline.detectDirectory`, `detectRuntime`; `MavenProjectHelper.detectRuntimeFromPom`, moved from `RunHelper`). - **The application properties are loaded once.** `Run` loaded them a second time to configure the logging (`loadProfileProperties`/`applyProfileProperties`, a copy of `RunProfileProperties`); it now only applies what only the command line has (the logging options, `background`, `jvmDebug`, the repositories and the Quarkus platform of the runs in another JVM). An empty run (`--empty`, `camel cmd send --local`) is configured with the application properties as before, with one difference: before, it only had them when the logging was on (they were loaded for the logging), and now also with `--logging=false`. `Run` is 1642 lines (2903 before stage 2), and `Run.run()` is the usage check, the request, the dispatch of the Maven runtimes, `--code`, the context, `configure`, the camel-launcher check of `--camel-version`, and the choice between another JVM and `start`. ## Tests - `RunExportGoldenTest`: no change to the expected files (45 tests, with the runs in this JVM). - `JBangRunnerTest` (new, 12 tests): a route that runs in this JVM until `maxMessages` with exit code 0 and the pid of the JVM, `stop()` ending a run that waits, a file without routes (exit code 1, "No routes found in: ..."), a directory that runs as the source directory, nothing to run (the "Cannot transform ..." message), a configured run started later, the prepared listener (with a file the caller adds first), an empty run that has the application properties, the reload-failure listener, and the JFR tests moved from camel-jbang-core. - `PreviousRunLogTest` (moved from `RunPreviousLogTest` in camel-jbang-core) tests the log of the previous run on the handle; `RunTest.theLogOfACommandLineRunIsKeptWithTheExitCodeOfTheCli` (new) checks that `camel run` asks for it and maps the exit code of a failed start (70). - camel-jbang-export: 229 tests pass. - camel-jbang-core: 2422 tests in the default fork and 287 in the serial fork. The only failures, `EvalSimpleTest` (it runs the Camel installed with JBang) and 9 tests of the AI tools about the elvis operator of Simple, fail on `main` locally too. - The Kubernetes, validate, test and TUI plugins compile with their tests, and the launcher compiles. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0128ThHB3iQdrvSRLVBGRrdP -- 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]
