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

   Item 4 of [CAMEL-26931](https://issues.apache.org/jira/browse/CAMEL-26931), 
the part about versions. The config part (`camel config set` and a bad config 
value) changes `CommandLineHelper`, which #29917 (local and global config are 
merged) changes too, so it comes after that PR.
   
   ## A --camel-version that does not exist
   
   `camel catalog`, `camel doc` and `camel validate` with a version that was 
never released answered "Cannot resolve dependencies in 
https://repo1.maven.org/maven2"; and exit 1, which reads like a network problem. 
The resolver tells the two apart: a version that does not exist ends in 
`ArtifactNotFoundException`, a repository that cannot be reached in 
`ArtifactTransferException`. `CatalogLoader.isArtifactNotFound` checks that 
every error of the resolution is a not-found, and not an offline repository. 
`CamelVersionCheck` makes that a not-found error, exit 3.
   
   ```
   $ camel catalog component --camel-version=9.9.9
   ERROR: Cannot resolve dependencies in https://repo1.maven.org/maven2         
                                            # main, exit 1
   ERROR: Camel version 9.9.9 not found in https://repo1.maven.org/maven2 
(camel version list shows the released versions)    # this branch, exit 3
   
   $ camel catalog component --runtime=spring-boot --camel-version=9.9.9
   ERROR: Camel Spring Boot version 9.9.9 not found in 
https://repo1.maven.org/maven2 (...)                                 # exit 3
   
   $ camel catalog component --camel-version=9.9.9 --repo=http://127.0.0.1:9
   ERROR: Cannot resolve dependencies in https://repo1.maven.org/maven2, 
http://127.0.0.1:9                                 # unchanged, exit 1
   ```
   
   The same for `camel doc` and `camel validate yaml`, and `--json` gives 
`{"status":"error","code":3,...}`. With the Quarkus runtime the version picks a 
platform, which reports its own errors, so that is left as it is.
   
   ## camel version set
   
   - It stored any value and exited 0, and every later command failed on it. It 
now checks in the Maven repositories (the `--repo`, or the stored `repos`) that 
`org.apache.camel:camel-api:pom:<version>` exists. A version that does not 
exist exits 3 and is not stored. When the repositories cannot be reached, the 
version is stored with a warning on stderr, so it works offline.
   - Without a version, `--runtime`, `--repo` or `--reset` it did nothing and 
exited 0; it is now a usage error, exit 2.
   - `--reset` also removes `repos` and `runtime`, which `version set` itself 
sets; that stays, and the option description and `camel-jbang-projects.adoc` 
now say so.
   
   ```
   $ camel version set 9.9.9
   ERROR: Camel version 9.9.9 not found (camel version list shows the released 
versions)    # exit 3, nothing stored
   $ camel version set
   ERROR: Give the Camel version to set, --runtime, --repo, or --reset          
            # exit 2
   $ camel version set 4.18.0                                                   
            # exit 0, stored
   ```
   
   Upgrade guide entry added.
   
   ## Tests
   
   - `CatalogLoaderNotFoundTest` (new): a not-found from central is a 
not-found; a refused connection, a mix of not-found and refused, an offline 
repository and other errors are not. The resolver exceptions are built in the 
test, so it needs no network.
   - `CamelVersionCheckTest` (new): the messages for Camel and Camel Spring 
Boot with the repository, null for a refused connection and for Quarkus.
   - `VersionSetTest`: the commands use a stub version check, so the tests do 
not ask Maven Central. New: a version that does not exist exits 3 and leaves 
the config as it was; a version that cannot be checked is stored with the 
warning, and the check gets the stored `repos`; a call with nothing to set 
exits 2 (it replaces the test that pinned the no-op).
   - The golden CLI help has the new `--reset` description.
   - End to end with the launcher built from this branch, as above.
   - camel-jbang-run: 307 pass. camel-jbang-core: 3005 + 261 pass. 
camel-jbang-plugin-validate: 23 pass.
   
   _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]

Reply via email to