Brijesh-Thakkar opened a new pull request, #27115:
URL: https://github.com/apache/camel/pull/27115
## Description
**CAMEL-24761: camel-jbang - cache the Camel version to Quarkus platform
mapping**
With `--runtime quarkus`, `QuarkusHelper.findQuarkusPlatformBom` queries the
Quarkus extension registry (`/client/platforms/all`) to find the Quarkus
platform matching the requested Camel version and then reads the platform BOM
POMs through Maven.
The registry response is already cached under
`~/.camel/quarkus-extension-registries/`, but the cache is only reused when it
was written *today* (`updatedToday`). As a result, released Camel versions
still trigger one registry request per day even though their mapping to a
Quarkus platform does not change.
This change persists the resolved Camel-to-Quarkus platform mapping
alongside the existing registry cache and reuses it indefinitely when the
mapping is final.
## What changes
All changes are contained in `QuarkusHelper.findQuarkusPlatformBom`. The
public method signature remains unchanged, so no caller changes are required
for `run`, `export`, `catalog`, `doc`, `dependency`, `validate`, MCP, or
Kubernetes callers.
A new cache file is stored at:
`~/.camel/quarkus-extension-registries/<host>/client/platforms/platform-mapping.json`
The file contains one mapping per requested Camel version:
```json
{
"4.14.5": {
"groupId": "io.quarkus.platform",
"version": "3.27.3.1"
}
}
```
The existing `Jsoner` / `JsonObject` API is used for reading and writing the
mapping.
On a cache hit, the same `QuarkusPlatformBom` as the original resolution is
reconstructed using the requested Camel version and the registry URI supplied
by the caller.
### When the mapping is reused
The cached mapping is reused without a TTL when:
* the registry is not a `file://` registry
* the requested Camel version is not a `-SNAPSHOT`
* `--fresh` is not set
* the cached entry is valid
In this case, the registry, Maven, and the BOM POMs are not accessed.
### When a mapping is stored
A mapping is stored only when the resolved platform's Camel version exactly
matches the requested released Camel version.
For example, if Camel `4.14.0` resolves to a platform containing Camel
`4.14.5`, the result is not cached. Similarly, if a Camel release does not have
a Quarkus platform published yet, the fallback result is not remembered.
This ensures that temporary or non-exact resolutions do not prevent a later,
correct platform from being discovered.
### `--fresh` and `--download=false`
* `--fresh` with downloading removes the mapping file and queries the
registry again.
* `--download=false` uses the mapping when available; otherwise it falls
back to the existing registry cache behaviour.
* `--fresh --download=false` continues to throw the existing "contradict
each other" exception. This behaviour is unchanged.
### Failure handling
A missing, unreadable, or corrupt mapping file is treated as a cache miss
and falls back to the existing resolution logic.
Entries with missing or blank fields are also treated as cache misses.
Only `IOException` and `DeserializationException` are handled when reading
the mapping. Mapping write failures are ignored so they do not affect the
normal resolution flow.
### Not changed
* The Camel Quarkus version is not stored because it is not used by callers.
* MCP and Kubernetes callers that hard-code `fresh=false` are unchanged.
* `file://` registries are not cached.
## Tests
Added 12 offline tests to `QuarkusHelperTest` using WireMock and per-test
temporary directories. The tests do not use the real `~/.camel` directory or
perform Maven downloads.
The tests cover:
* storing a mapping after the first successful resolution
* reusing a mapping without accessing the registry or Maven
* verifying that the cached BOM matches the original resolution
* reusing mappings after the registry cache becomes old
* ensuring non-exact platform matches are not cached
* ensuring `SNAPSHOT` versions are never cached or looked up
* `--fresh` removing and rebuilding the mapping
* `--fresh --download=false` continuing to throw
* `--download=false` with and without an existing registry cache
* multiple forms of corrupt mapping files
* unreadable mapping paths
* ensuring `file://` registries are not cached
The tests use the `quarkus-registry-client-platforms.json` fixture because
`registry.quarkus.io/.../all.json` contains releases whose matching BOM POMs
are not available in the test resources.
## Verification
Verification was performed using `./mvnw` with Maven 3.9.16, as pinned by
the repository.
* `./mvnw formatter:format impsort:sort` leaves the tree unchanged.
* `./mvnw -Psourcecheck validate` passes.
* `QuarkusHelperTest`: 15 tests, 0 failures.
* `QuarkusPlatformMixinTest`: 7 tests, 0 failures.
* Full `camel-jbang-core` test suite: 1275 tests, 0 failures, 0 errors, 2
skipped.
Four tests (`ExpressionEvaluatorTest` and three `bind` tests) initially
failed because of `Connection timed out` errors and passed when rerun. The same
intermittent failures occur on `main` and are unrelated to this change.
The exact command `mvn clean install -DskipTests` was not run. A `-Dquickly`
reactor install was used during development instead.
System Maven 3.9.12 also fails in `camel-kserve` with a Guice error in
`protobuf-maven-plugin`; this is unrelated to the change.
## Documentation
No documentation changes are required.
There is currently no camel-jbang documentation describing this cache. The
Camel 4.21 upgrade guide states that the registry is fetched "at most once a
day", which remains accurate for mappings that are not final released mappings.
*Claude Code on behalf of Brijesh-Thakkar*
---
## Checklist
### 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)](https://issues.apache.org/jira/browse/CAMEL)
filed for the change (usually before you start working on it).
### Apache Camel coding standards and style
* [ ] I checked that each commit in the pull request has a meaningful
subject line and body.
* [ ] I have run `mvn clean install -DskipTests` locally from root folder
and I have committed all auto-generated changes.
### AI-assisted contributions
* [ ] 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]