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

   # Description
   
   JIRA: [CAMEL-26558](https://issues.apache.org/jira/browse/CAMEL-26558)
   
   ## What is wrong
   
   `camel export --runtime=quarkus` never writes 
`org.apache.camel.quarkus:camel-quarkus-microprofile-health` to the exported 
`pom.xml`, whichever way the project asks for it. `QuarkusExporter` 
(`ExportQuarkus` in `camel-jbang-core` up to 4.23) treats the extension as one 
that `quarkus-pom.ftl` always contains and removes it twice: 
`resolveDependencies` removes every dependency that contains 
`camel-microprofile-health` as an "out of the box" dependency, and 
`buildQuarkusDependencyList` skips `camel-quarkus-microprofile-health` 
("Special case, quarkus-pom.ftl already has them included."). The template 
contains only `camel-quarkus-core`, though, so the export reports success, and 
the exported application starts without SmallRye Health: it has no `/q/health` 
and no Camel health checks.
   
   | Dependency | Removed by |
   |---|---|
   | `--dep=camel:microprofile-health` | `resolveDependencies` |
   | `--dep=org.apache.camel:camel-microprofile-health` | `resolveDependencies` 
|
   | `--dep=org.apache.camel.quarkus:camel-quarkus-microprofile-health` | 
`buildQuarkusDependencyList` |
   | `camel.jbang.dependencies=camel:microprofile-health` | 
`resolveDependencies` |
   
   `camel run --runtime=quarkus` exports the project with `QuarkusExporter` as 
well (`ProjectRunner`) and is affected the same way. CAMEL-18719 (3.20.0) added 
the skip for `camel-quarkus-core`, `camel-quarkus-platform-http` and 
`camel-quarkus-microprofile-health`, the three extensions the template 
contained then. When 0f60409d5ceb took `camel-quarkus-platform-http` out of the 
template, it removed its skip and its `removeIf` with it. #17296 (4.11.0) 
replaced `camel-quarkus-microprofile-health` in the template with 
`camel-quarkus-observability-services`, which depends on the health extension, 
but kept its two exclusions; CAMEL-22187 (4.14.0) then removed 
`camel-quarkus-observability-services` from the template as well, so that only 
`--observe` adds it (`camel kubernetes export` always sets it). 4.23.0, 
`camel-4.23.x`, `camel-4.22.x`, `camel-4.18.x` and `main` are affected.
   
   ## Steps to reproduce
   
   ```shell
   camel init hello.camel.yaml
   camel export hello.camel.yaml --runtime=quarkus 
--gav=org.example:hello:1.0.0 --dir=out \
     --dep=camel:microprofile-health --dep=camel:jackson
   grep -E -o 'camel-quarkus-(microprofile-health|jackson)' out/pom.xml
   # camel-quarkus-jackson
   ```
   
   ## Fix
   
   - `QuarkusExporter.resolveDependencies` no longer removes 
`camel-microprofile-health`.
   - `QuarkusExporter.buildQuarkusDependencyList` no longer skips 
`camel-quarkus-microprofile-health`.
   - `camel-quarkus-core` is still left to the template, in both places. This 
is what 0f60409d5ceb did for `camel-quarkus-platform-http`.
   
   Adding the extension to `quarkus-pom.ftl` again would also fix the dropped 
dependency, but would put it into every export, while CAMEL-22187 made it 
opt-in together with the other observability services.
   
   ## Behaviour change
   
   - A Quarkus export now has `camel-quarkus-microprofile-health` when the 
project lists it in any of the spellings above. Documented in 
`camel-4x-upgrade-guide-4_24.adoc`.
   - Without the dependency nothing changes: the health extension then only 
comes with `--observe` (always set by `camel kubernetes export`), as part of 
`camel-quarkus-observability-services`. With `--observe` and the dependency, 
the `pom.xml` has both; the extension is the same.
   - The Camel Main and Spring Boot exports are not changed.
   
   ## Tests
   
   | Test | Asserts |
   |---|---|
   | `ExportTest.shouldExportMicroProfileHealthToQuarkus` (3 spellings) | the 
exported `pom.xml` has 
`org.apache.camel.quarkus:camel-quarkus-microprofile-health` exactly once, 
without a version |
   | `ExportTest.shouldExportCamelQuarkusCoreOnceToQuarkus` (3 spellings) | 
`camel-quarkus-core`, which the template contains, is still in the `pom.xml` 
only once |
   
   The three `shouldExportMicroProfileHealthToQuarkus` cases fail against 
`main` (`Expected size: 1 but was: 0`). With only the exclusion in 
`resolveDependencies` put back, the `camel:` and `org.apache.camel:` cases 
still fail, so each exclusion is covered on its own. 
`shouldExportCamelQuarkusCoreOnceToQuarkus` passes on `main`; it fails for 
`org.apache.camel.quarkus:camel-quarkus-core` (`Expected size: 1 but was: 2`) 
when the `camel-quarkus-core` check in `buildQuarkusDependencyList` is taken 
out. In `dsl/camel-jbang/camel-jbang-run`, `QuarkusExporterTest`, 
`ProjectExporterTest`, `ExportHelperTest`, `ExporterCopySourceFilesTest`, 
`ExporterTest` and `SpringBootExporterTest` (40 tests), and in 
`dsl/camel-jbang/camel-jbang-core`, `ExportTest`, `RunExportGoldenTest`, 
`ExportApiTest`, `ExportMainJibTest` and `ExportMainJkubeTest` (184 tests) are 
green on top of the current `main`. I left out the five 
`ExportTest.shouldExportWith*Repos*` tests, because they download from 
repositories that
  the network I tested in does not answer; they only check the repositories in 
the generated `pom.xml`. A root `mvn clean install -DskipTests` leaves no 
uncommitted changes. With the fix, the reproducer above run with the locally 
built Camel CLI 4.24.0-SNAPSHOT prints `camel-quarkus-jackson` and 
`camel-quarkus-microprofile-health`; with Camel CLI 4.23.0 and 4.22.1 it prints 
the output shown. I built and started both exported projects: without the fix 
the application has no HTTP server and no `/q/health`; with the fix it has the 
`smallrye-health` feature and `GET /q/health` returns `UP` with the Camel 
checks.
   
   _Changes prepared with Claude Code on behalf of @tools400._
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   <!--
   # *Note*: trivial changes like, typos, minor documentation fixes and other 
small items do not require a JIRA issue. In this case your pull request should 
address just this issue, without pulling in other changes.
   -->
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   
   <!--
   If you're unsure, you can format the pull request title like `[CAMEL-XXX] 
Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the 
appropriate JIRA issue.
   -->
   
   - [x] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
   
   <!--
   You can run the aforementioned command in your module so that the build 
auto-formats your code. This will also be verified as part of the checks and 
your PR may be rejected if if there are uncommited changes after running `mvn 
clean install -DskipTests`.
   
   You can learn more about the contribution guidelines at 
https://github.com/apache/camel/blob/main/CONTRIBUTING.md
   -->
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
   


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

  • [PR] CAMEL-26558: camel-jbang... tools400 (via GitHub) via commits

Reply via email to