Skip to content

SOLR-17697 Use picocli instead of commons-cli - #3254

Draft
janhoy wants to merge 21 commits into
mainfrom
jira/SOLR-17697-picocli
Draft

SOLR-17697 Use picocli instead of commons-cli#3254
janhoy wants to merge 21 commits into
mainfrom
jira/SOLR-17697-picocli

Conversation

@janhoy

@janhoy janhoy commented Mar 11, 2025

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/SOLR-17697

This PR is just a way to visualize the status of the feature branch jira/SOLR-17697-picocli.
Create PRs targeting that branch to tackle individual tasks, and then squash merge into this feature branch once done. Then at the end this branch can be merged (not-squash) into main to preserve each tool porting.

Pick a tool not yet converted from the list below. You'll find a useful LLM prompt template in the JIRA issue linked above. Feel free to link your PR number next to the tool line below to signal that you are working on it. Once merged into the feature-branch, check the checkbox.

Tasks/milestones:

@xtenzQ

xtenzQ commented Mar 21, 2025

Copy link
Copy Markdown
Contributor

Actually, I'd like to try to implement PoC for few initial tools.

upd: oh, I didnt notice there is a PR created for this

@janhoy

janhoy commented Mar 21, 2025

Copy link
Copy Markdown
Contributor Author

upd: oh, I didnt notice there is a PR created for this

Yea, there's an in-progress exploration taking place, feel free to join the discussion about it or POC for yourself on how to solve various issues that arise. We're still trying to land on the most elegant way to introduce things, and I plan to dial down the ambitions for the other PR to do bare minimal for one or two tools, and perhaps the "start" tool. Eventually, when we start getting the grip on how things should flow, it will be easier to jump in and implement PRs for new tools, targeting this branch.

@janhoy
janhoy force-pushed the jira/SOLR-17697-picocli branch from 4ddb026 to 97a673e Compare April 5, 2026 12:45
@janhoy
janhoy force-pushed the jira/SOLR-17697-picocli branch from 97a673e to cb41a69 Compare April 5, 2026 12:50
@epugh

epugh commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Let's get this into main as soon as possible!!!

@janhoy

janhoy commented Apr 7, 2026

Copy link
Copy Markdown
Contributor Author

@xtenzQ Everything is now brought up to speed with main. I have merged the first few tools into the feature branch. And I have two in-flight PRs ready for review and merging into this branch. See a comment in the JIRA issue for how to contribute for other tools not yet converted.

@github-actions github-actions Bot added the tests label Apr 7, 2026
Comment thread solr/core/src/java/org/apache/solr/cli/VersionTool.java Outdated
Comment thread solr/core/src/java/org/apache/solr/cli/StartCommand.java Outdated
@epugh

epugh commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

@jaykay12 this is the ticket I mentioned in JIRA with a whole bunch of items to be worked on in hte description of the PR. Please tag me on your PR's to this branch, as I'd love to see this get over the finish line soon!

janhoy added 4 commits July 30, 2026 15:20
…ocli

# Conflicts:
#	solr/api/gradle.lockfile
#	solr/benchmark/gradle.lockfile
#	solr/core/gradle.lockfile
#	solr/core/src/java/org/apache/solr/cli/ConfigSetUploadTool.java
#	solr/core/src/java/org/apache/solr/cli/CreateTool.java
#	solr/core/src/java/org/apache/solr/cli/DeleteTool.java
#	solr/core/src/java/org/apache/solr/cli/StatusTool.java
#	solr/core/src/java/org/apache/solr/cli/VersionTool.java
#	solr/cross-dc-manager/gradle.lockfile
#	solr/modules/analysis-extras/gradle.lockfile
#	solr/modules/clustering/gradle.lockfile
#	solr/modules/cross-dc/gradle.lockfile
#	solr/modules/cuvs/gradle.lockfile
#	solr/modules/extraction/gradle.lockfile
#	solr/modules/gcs-repository/gradle.lockfile
#	solr/modules/jwt-auth/gradle.lockfile
#	solr/modules/langid/gradle.lockfile
#	solr/modules/language-models/gradle.lockfile
#	solr/modules/ltr/gradle.lockfile
#	solr/modules/opentelemetry/gradle.lockfile
#	solr/modules/s3-repository/gradle.lockfile
#	solr/modules/scripting/gradle.lockfile
#	solr/modules/sql/gradle.lockfile
#	solr/packaging/build.gradle
#	solr/packaging/test/test_create.bats
#	solr/server/gradle.lockfile
#	solr/solr-ref-guide/gradle.lockfile
#	solr/solrj-jetty/gradle.lockfile
#	solr/solrj-streaming/gradle.lockfile
#	solr/solrj-zookeeper/gradle.lockfile
#	solr/solrj/gradle.lockfile
#	solr/test-framework/build.gradle
#	solr/test-framework/gradle.lockfile
#	solr/webapp/gradle.lockfile
…igSets API changes

- DeleteTool: use CLIUtils.getSolrConnection and 'Connecting to Solr at' message
  as on main, since delete no longer talks to ZooKeeper directly
- CreateTool: only take solrUrl from explicit connection options so the
  live-node URL fallback works again (as on main)
- StatusTool: default picocli --max-wait-secs to 0 to avoid NPE
…n changes

- SolrCLI --version now prints 'Client version:' matching commons-cli output
- ZkConnectionOptions, ConnectionOptions (create/delete) and StatusTool gain
  -s/--solr-connection accepting a ZooKeeper or HTTP(s) connection string,
  with --solr-url now long-only, mirroring CommonCLIOptions on main
- StatusTool picocli target options grouped mutually exclusive like the
  commons-cli OptionGroup; zk/connection targets resolved to a Solr URL via
  new shared CLIUtils.solrUrlFromConnection (extracted from normalizeSolrUrl)
- CliDefaultValueProvider supports SOLR_CONNECTION env default
- test_status.bats accepts both engines' mutual-exclusion error messages

Connection parsing is string-only; network calls happen only at tool
execution time, never during picocli parsing.
@janhoy

janhoy commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

This branch is now up to date with latest main (~250 commits merged in). All of precommit, the CLI unit tests (org.apache.solr.cli.*), and the create/delete/status/version/zk BATS suites pass — the BATS suites in both default commons-cli mode and with SOLR_PICOCLI=true.

What it took, beyond routine conflict resolution:

  • Regenerated all gradle lockfiles (resolveAndLockAll --write-locks plus a precommit --write-locks pass for the jar-check *Copy configurations), and dropped permitUnusedDeclared from test-framework/build.gradle — replaced on main by the opt-in DAGP plugin.
  • Adopted main's move away from direct ZooKeeper access: DeleteTool now resolves its target via CLIUtils.getSolrConnection and deletes configsets through the ConfigSets API (echoing "Connecting to Solr at …"); CreateTool uses the new CloudSolrClientConnection API with the isZookeeper() guard for config upload, and only takes the Solr URL from explicit connection options so the live-node fallback works as on main.
  • Brought the picocli path to parity with main's --solr-connection change (-s now means --solr-connection, --solr-url is long-only) in ZkConnectionOptions, the create/delete ConnectionOptions, and StatusTool — whose picocli target options are now a mutually-exclusive group mirroring the commons-cli OptionGroup. Connection parsing is string-only; network calls happen only at tool execution time, never during picocli parsing.
  • solr --version under picocli now prints Client version: … to match main's new commons-cli output (which also prints Server version: when a connection option is given).
  • Small fixes along the way: defaulted picocli --max-wait-secs to 0 (NPE for plain solr status), and relaxed the test_status.bats mutual-exclusion assertion to accept both engines' error messages (same pattern as test_create.bats).

The zk→live-node URL resolution needed by StatusTool was extracted into CLIUtils.solrUrlFromConnection(), proposed separately against main in #4683 to keep non-picocli drift off this branch.

janhoy added 5 commits July 30, 2026 16:50
Import IOException in ConnectionOptions and picocli.CommandLine in
SolrCLITest instead of using fully qualified names.
The picocli field refactor made the credential-taking overload read the
(unset) field instead of its parameter, so AssertTool's status checks sent
no Authorization header and test_basic_auth.bats failed with 401.
…ages

Project.javaexec was removed in Gradle 9 (which arrived with the main
merge); use injected ExecOperations as done in gradle/globals.gradle.
Regenerated pages/cli to reflect the new -s/--solr-connection option
group on status, create, delete and zk subcommands.
# Conflicts:
#	solr/core/src/java/org/apache/solr/cli/AuthTool.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants