Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Migrates PackageTool to picocli while retaining the legacy Commons CLI path.
Changes:
- Adds picocli options, execution, and connection resolution.
- Runs existing package tests through both CLI paths.
- Registers and documents the package command.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
solr/core/src/java/org/apache/solr/cli/PackageTool.java |
Implements picocli support. |
solr/core/src/java/org/apache/solr/cli/SolrCLI.java |
Registers the package subcommand. |
solr/core/src/test/org/apache/solr/cli/PackageToolTest.java |
Generalizes tests across invocation paths. |
solr/core/src/test/org/apache/solr/cli/PackageToolPicocliTest.java |
Exercises the picocli path. |
solr/solr-ref-guide/modules/deployment-guide/pages/cli/solr-package.adoc |
Adds generated CLI documentation. |
solr/solr-ref-guide/modules/deployment-guide/deployment-nav.adoc |
Adds package documentation navigation. |
Suppressed comments (1)
solr/core/src/java/org/apache/solr/cli/PackageTool.java:164
- This drops the legacy
-pspelling for package parameters. The existing package usage text still advertises-p(line 423), and the test comment identifies it as a deprecated value that must continue to work; picocli will reject it unless it is declared explicitly.
names = {"--param"},
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
janhoy
left a comment
There was a problem hiding this comment.
This is a complex tool, congratulations on picking it 😉
Main comment is that we should use Picoclis sub commands to drive the command param/options parsing, help output and auto-generated docs. It's not a goal to preserve 1:1 help output from commons-cli.
I used Claude Code to help me find discrepancies and author these review comments, so bear over with it being detailed some places.
| } | ||
| String defaultUrl = CLIUtils.getDefaultSolrUrl(); | ||
| CLIO.err( | ||
| "Neither --solr-connection, --zk-host or --solr-url parameters, nor SOLR_CONNECTION, ZK_HOST env var provided, so assuming solr url is " |
There was a problem hiding this comment.
This message promises more than the code delivers: the only fallback actually consulted is EnvUtils.getProperty("zkHost") (line above, and again in resolveZkHost). SOLR_CONNECTION / the solrConnection property is never read, so it works under commons-cli (via CLIUtils.resolveSolrConnectionFromCli) but is silently ignored on the picocli path — while this message claims it was checked.
Worth noting the underlying cause is a framework gap rather than something to solve per-tool: picocli doesn't apply the CliDefaultValueProvider to @ArgGroup members when the group is unmatched, which is exactly why connectionOptions can be null here. That's the still-unchecked "Solve value-fallback to ENV" milestone on #3254.
If you spin this into a separate PR, then add a TODO or NOCOMMIT comment with a link so we know there is a bug here that depends on some other PR.
There was a problem hiding this comment.
Took help of cursor to understand this, still not fully sure of the implications here.
AI reply:
Fixed on the picocli path: when the ArgGroup is unmatched we read solr-connection / zkHost from env before the default URL, so the message matches behaviour. The ArgGroup default-provider issue remains #3254.
|
Heads up that we're about to push a change to main that refactors all the Tools for easier picocli migration. This means eventually the feature branch will have a changed |
AI Generated High Level changes:flowchart TB
subgraph user [User]
CLI["bin/solr package …"]
end
CLI --> SOLRCLI[SolrCLI]
SOLRCLI --> FLAG{picocli flag?}
FLAG -->|no: commons-cli| PT_CLI[PackageTool.runImpl]
PT_CLI --> EXEC[executePackage<br/>logger OFF + resolve via CLIUtils]
EXEC --> SWITCH[handleCommand switch]
SWITCH --> HELPERS
FLAG -->|yes: picocli| PT_PICO[PackageTool parent]
PT_PICO --> SUB{subcommand}
SUB --> AddRepo
SUB --> AddKey
SUB --> ListInstalled
SUB --> ListAvailable
SUB --> ListDeployed
SUB --> Install
SUB --> Deploy
SUB --> Undeploy
SUB --> Uninstall
SUB -.->|bare package| USAGE[print usage + notes a/b]
AddRepo & AddKey & ListInstalled & ListAvailable & ListDeployed & Install & Deploy & Undeploy & Uninstall --> PSC[PackageSubCommand.runWithManagers]
PSC --> RWM[PackageTool.runWithManagers<br/>logger OFF]
RWM --> CONN[ConnectionOptions.resolveSolrUrl / resolveZkHost<br/>flags, then SOLR_CONNECTION / ZK_HOST]
CONN --> HELPERS[shared helpers:<br/>addRepo, install, deploy, …]
HELPERS --> PM[PackageManager / RepositoryManager]
flowchart LR
subgraph before [Before this PR]
B1["one PackageTool"]
B2["cmd + ARGS catch-all"]
B3["hand-written switch"]
B1 --> B2 --> B3
end
subgraph after [After]
A1["PackageTool parent"]
A2["9 picocli leaves"]
A3["shared helpers + ConnectionOptions"]
A1 --> A2 --> A3
end
before --> after
|
| String solrConnectionProp = EnvUtils.getProperty("solr-connection"); | ||
| if (solrConnectionProp != null && !solrConnectionProp.isBlank()) { | ||
| var connection = CloudSolrClient.CloudSolrClientConnection.parse(solrConnectionProp); | ||
| if (connection.isZookeeper()) { | ||
| return solrConnectionProp; | ||
| } | ||
| } | ||
|
|
||
| String zkHostProp = EnvUtils.getProperty("zkHost"); | ||
| if (zkHostProp != null && !zkHostProp.isBlank()) { | ||
| return zkHostProp; | ||
| } |
| @picocli.CommandLine.Option( | ||
| names = {"-p", "--param"}, | ||
| paramLabel = "PARAMS", | ||
| description = "List of parameters to be used with deploy command.") |
|
I had a look and there is still have lots of review comments to make, will try to address them in the coming days. Meantime, I intend to merge #3254 to main, meaning this PR will automatically also target main branch. Otherwise things should be equal. |
janhoy
left a comment
There was a problem hiding this comment.
Can we prefix these sub command class names with Pkg (similar to Zk*) to namespace them and make it obvious what tool they are for.
|
I did not intend to close the issue, but it was auto closed when the feature branch was deleted. I expected Github to auto move this onto main. I cannot seem to re-target the PR either, so please re-open one targeting main. When doing so, please let it reference https://issues.apache.org/jira/browse/SOLR-18515 which is a new dedicated JIRA for this tool. Again, sorry for the inconvenience. |



https://issues.apache.org/jira/browse/SOLR-17697
Description
Implementing PicoCLI for the PackageTool
Solution
Used Prompt provided in the Jira & got initial migration done by Cursor.
Majoryly, common code which was being used in the commons-cli call path, which could be used in picocli as well, is being refactored to private functions.
#4739 (comment)
Tests
Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
Checklist
Please review the following and check all that apply:
mainbranch../gradlew check.