-
Notifications
You must be signed in to change notification settings - Fork 418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Annotation processor gives FATAL ERROR: picocli.CommandLine$InitializationException: ArgGroup has no options or positional parameters, and no subgroups #794
Comments
…cting the model To prevent FATAL ERROR: picocli.CommandLine$InitializationException: ArgGroup has no options or positional parameters, and no subgroups
To prevent FATAL ERROR: picocli.CommandLine$InitializationException: ArgGroup has no options or positional parameters, and no subgroups
This is hitting me when launching picocli 4.2.0 from IntelliJ Idea, even with Annotation Processor enabled. It works well compiling and launch it from the terminal.
|
Recently I occasionally encounter this in intelli/j. I’ve been able to resolve it by specifying a different JDK than the one that’s built-in to Intelli/J.
|
Yes, using IntelliJ Idea 2019.3 with a separate JDK 1.8.0_141. The error happens when we add a second subcommand with Annotation Processors enabled. EDIT: no problem, thanks for the prompt response |
Ok, that is interesting. Can you provide your command(s) so I can try to reproduce it? |
It's a quite big application, these are the relevant parts: KtmCli.java: @Command(name = "ktm-cli", description = "xxx",
version = KtmCli.PROJECT_VERSION, subcommands = {KtmTopic.class, KtmSanityCheck.class}
)
@Slf4j
public class KtmCli {
} KtmTopic.java: @Command(name = "topic", description = "yyyy",
mixinStandardHelpOptions = true, exitCodeListHeading = "Exit Codes:%n",
exitCodeList = {EXIT_SUCCESS + ": successful program execution",
EXIT_ERROR_CONFIG_CLIENT + ": error in config client",
EXIT_ERROR_CONFIG_TOPIC + ": error in config topic", EXIT_ERROR_GENERIC + ": error in execution time"})
@Slf4j
public class KtmTopic implements Callable<Integer> {
@ArgGroup(exclusive = ActionGroup.EXCLUSIVE, multiplicity = "0..1", heading = "\n" + ActionGroup.GROUP_KEY + ":\n")
private ActionGroup actionGroup;
@ArgGroup(exclusive = ConfigGroup.EXCLUSIVE, multiplicity = "0..1", heading = "\n" + ConfigGroup.GROUP_KEY + ":\n")
private ConfigGroup configGroup;
@ArgGroup(exclusive = LogGroup.EXCLUSIVE, multiplicity = "0..1", heading = "\n" + LogGroup.GROUP_KEY + ":\n")
private LogGroup logGroup;
@ArgGroup(exclusive = TopicGroup.EXCLUSIVE, multiplicity = "1", heading = "\n" + TopicGroup.GROUP_KEY + ":\n")
private TopicGroup topicGroup; KtmSanityCheck.java: @Command(name = "sanity", description = "zzzzz",
mixinStandardHelpOptions = true, exitCodeListHeading = "Exit Codes:%n",
exitCodeList = {EXIT_SUCCESS + ": successful program execution",
EXIT_ERROR_CONFIG_CLIENT + ": error in config client"})
@Slf4j
public class KtmSanityCheck implements Callable<Integer> {
@ArgGroup(exclusive = ConfigGroup.EXCLUSIVE, multiplicity = "0..1", heading = "\n" + ConfigGroup.GROUP_KEY + ":\n")
private ConfigGroup configGroup;
@ArgGroup(exclusive = LogGroup.EXCLUSIVE, multiplicity = "0..1", heading = "\n" + LogGroup.GROUP_KEY + ":\n")
private LogGroup logGroup; |
I am consistently hitting this issue in IntelliJ. I have a (root)command and a bunch of subcommands separated in different files, one of these subcommands contains two Interestingly, if I modify something the Java file of the root command and try to rebuild, I consistently get this error:
However, if I then modify anything in the Java file of the subcommand with the two IntelliJ version: 2019.3.5 |
@hatyo I still occasionally see this error when a project is incrementally compiled in Intelli/J. Is this your experience too? It may be an issue of intelli/J's incremental compilation and may not be a problem in picocli. |
Picocli 4.5 has been released, which includes this fix. |
(Related to #793) The annotation processor occasionally gives this error for composite groups:
This is not easy to reproduce but may happen when building from Gradle or when an arg group is used as both a field and as a parameter in a
@Command
-annotated method.The cause is likely that the annotation processor depends on the
javac
compiler to present@ArgGroup
-annotated elements in topologically sorted order (so the groups with no dependencies on other groups come first, and groups that depend on other groups come later).When this assumption is broken, the above error may occur if a composite arg group is built before its subgroups are built.
The solution is for the annotation processor to do its own topological sorting and not depend on javac.
The text was updated successfully, but these errors were encountered: