Skip to content

SOLR-18517: Port RunExampleTool to picocli - #5050

Merged
janhoy merged 7 commits into
apache:mainfrom
serhiy-bzhezytskyy:SOLR-18517-picocli-run-example
Oct 8, 2026
Merged

janhoy merged 7 commits into
apache:mainfrom
serhiy-bzhezytskyy:SOLR-18517-picocli-run-example

Conversation

@serhiy-bzhezytskyy

Copy link
Copy Markdown
Contributor

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

Description

Adds the picocli code path for run_example, which bin/solr start -e calls, next to the commons-cli one.

Solution

RunExampleTool gets its annotated options and callTool() and is registered in SolrCLI; the commons-cli path is unchanged. The options are the ones the bin/solr scripts pass, including --script-inputs. The command is only invoked by the scripts, so it is hidden and has no reference page. Written with Claude Code.

Tests

SolrCLIRunExamplePicocliTest runs the existing TestSolrCLIRunExample through picocli, and checks that the port and --zk-host defaults come from the properties. With SOLR_PICOCLI=true, bin/solr start -e techproducts starts and indexes the example. check -x test is clean (rat skipped).

Checklist

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide
  • I have added a changelog entry for my change

Adds the picocli code path next to the commons-cli one, so that bin/solr start -e works with the picocli parser, with a test twin. The command is called only by the bin/solr scripts, so it is hidden from the generated reference.

@janhoy janhoy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generic changelog comment, and a behavior diff from commons-cli

Comment thread changelog/unreleased/SOLR-18517-picocli-run-example.yml Outdated
Comment thread solr/core/src/java/org/apache/solr/cli/RunExampleTool.java
No picocli feature has been released yet, so a new command is a detail of the SOLR-17697 entry. Its author and JIRA are added there instead of a separate entry.
…run_example

bin/solr passes -Dname=value arguments on to run_example. commons-cli takes them out before parsing (SolrCLI.parseCmdLine) and hands them on as extra arguments, but picocli rejected the first one as an unknown option. They are now collected as unmatched options and kept as extra arguments after the positional ones; any other unknown option still ends in picocli's usage error, exit code 2.
…ts test sets

AGENTS.md says the base classes restore system properties after each test, so the try/finally with clearProperty is dropped; the check that the port defaults to 8983 without the property becomes a test of its own.
@janhoy
janhoy merged commit d94c5ee into apache:main Oct 8, 2026
1 check passed
@janhoy janhoy added this to the 10.x milestone Oct 8, 2026
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.

2 participants