Skip to content

Remove deprecated @GroupCommandDefinition (Phase 2) #526

@stalep

Description

@stalep

Summary

@GroupCommandDefinition is now redundant. All its attributes are available on @CommandDefinition, which gained groupCommands() in a previous release. The two annotations are functionally identical — the only difference is that @GroupCommandDefinition lacks disableParsing() (which is ignored for group commands anyway).

Current state

Attribute @CommandDefinition @GroupCommandDefinition
name
description
aliases
generateHelp
version
validator
resultHandler
activator
defaultValueProvider
stopAtFirstPositional
sortOptions
helpUrl
helpGroup
helpSectionProvider
groupCommands
disableParsing ❌ (N/A for groups)

Migration path

Replace:

@GroupCommandDefinition(name = "git", description = "Git",
        groupCommands = {CommitCmd.class, PushCmd.class})

With:

@CommandDefinition(name = "git", description = "Git",
        groupCommands = {CommitCmd.class, PushCmd.class})

Proposed plan

Phase 1: Deprecate (this release)

  1. Add @Deprecated to @GroupCommandDefinition
  2. Add deprecation note to javadoc pointing to @CommandDefinition(groupCommands)
  3. Update project site documentation to use @CommandDefinition for all group command examples
  4. Update all internal tests and examples to use @CommandDefinition(groupCommands)

Phase 2: Remove (future release)

  1. Remove @GroupCommandDefinition annotation
  2. Remove the GroupCommandDefinition handling branch in AeshCommandContainerBuilder.doGenerateCommandLineParser()
  3. Remove the GroupCommandDefinition handling in CodeGenerator (processor)
  4. Remove from AeshCommandContainerBuilder.getCommandAliases() and getCommandName() fallbacks

What needs to change in aesh

aesh module:

  • AeshCommandContainerBuilder.doGenerateCommandLineParser() — has separate branch for @GroupCommandDefinition (lines ~189-247). The @CommandDefinition branch already handles groupCommands.length > 0. The @GroupCommandDefinition branch can be removed once deprecated.
  • AeshCommandContainerBuilder.getCommandAliases() / getCommandName() — fallback checks for @GroupCommandDefinition. Can be removed.

aesh-processor module:

  • CodeGenerator — handles @GroupCommandDefinition separately from @CommandDefinition. Both paths generate equivalent code. Can be unified.
  • AeshAnnotationProcessor — scans for both annotation types. Can be simplified.

Impact

  • jbang: Uses @CommandDefinition(groupCommands) already (migrated in the aesh migration). No impact.
  • Existing aesh users: Any code using @GroupCommandDefinition needs to switch to @CommandDefinition(groupCommands). This is a mechanical replacement — same attributes, same behavior.
  • Tests: ~15 test classes use @GroupCommandDefinition. These should be migrated in Phase 1 to validate the @CommandDefinition path.

Context

@GroupCommandDefinition was the original way to define group commands. When groupCommands() was added to @CommandDefinition, both annotations became functionally identical. Having two ways to do the same thing adds confusion and maintenance burden (two code paths in the builder, two paths in the processor, documentation must explain both).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions