Skip to content
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

picocli should be able to mark its annotation dependent classes as unremovable #38077

Closed
maxandersen opened this issue Jan 6, 2024 · 4 comments · Fixed by #38083
Closed

picocli should be able to mark its annotation dependent classes as unremovable #38077

maxandersen opened this issue Jan 6, 2024 · 4 comments · Fixed by #38083
Labels
area/picocli kind/enhancement New feature or request
Milestone

Comments

@maxandersen
Copy link
Contributor

maxandersen commented Jan 6, 2024

Description

For example:

@Command(name = "hassq", mixinStandardHelpOptions = true, 
          subcommands = { StateCommand.class, AreaCommand.class, EntityCommand.class, EventCommand.class, ConfigCommand.class},
          versionProvider = VersionProvider.class)

and then VersionProvider looks like this:

@Unremovable @Singleton
public class VersionProvider implements IVersionProvider {

    @ConfigProperty(name = "quarkus.application.version")
    String version;

    @Override
    public String[] getVersion() throws Exception {
        return new String[] { version };
    }
}

This is picked up by quarkus picocli extension as we provided a picocli IFactory.

It shouldn't be necessary to specify @unremovable in this case should it ? Right now it is required though.

There are multiple other class references via annotation in picocli apis:

rg "Class<\? extends .*>.*default"
src/main/java/picocli/CommandLine.java
3960:        Class<? extends ITypeConverter<?>>[] converter() default {};
4016:        Class<? extends Iterable<String>> completionCandidates() default NoCompletionCandidates.class;
4126:        Class<? extends IParameterConsumer> parameterConsumer() default NullParameterConsumer.class;
4131:        Class<? extends IParameterPreprocessor> preprocessor() default NoOpParameterPreprocessor.class;
4262:        Class<? extends ITypeConverter<?>>[] converter() default {};
4313:        Class<? extends Iterable<String>> completionCandidates() default NoCompletionCandidates.class;
4360:        Class<? extends IParameterConsumer> parameterConsumer() default NullParameterConsumer.class;
4377:        Class<? extends IParameterPreprocessor> preprocessor() default NoOpParameterPreprocessor.class;
4642:        Class<? extends IVersionProvider> versionProvider() default NoVersionProvider.class;
4757:        Class<? extends IDefaultValueProvider> defaultValueProvider() default NoDefaultProvider.class;
4876:        Class<? extends IModelTransformer> modelTransformer() default NoOpModelTransformer.class;
4881:        Class<? extends IParameterPreprocessor> preprocessor() default NoOpParameterPreprocessor.class;

and I expect all of these will today require @unremovable even though we should be able to detect that picocli will eventually need them.

Suggestion is thus that Arc gets instructed to leave these around if beans are of any of those types.

Anyone see an issue making this happen?

Implementation ideas

No response

@maxandersen maxandersen added the kind/enhancement New feature or request label Jan 6, 2024
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 6, 2024

/cc @ebullient (picocli)

@maxandersen
Copy link
Contributor Author

This is semi-related to #29379

@geoand
Copy link
Contributor

geoand commented Jan 8, 2024

Let me have a look

@geoand
Copy link
Contributor

geoand commented Jan 8, 2024

#38083 takes care of it

gsmet added a commit that referenced this issue Jan 9, 2024
Make Picocli version providers unremovable classes
@quarkus-bot quarkus-bot bot added this to the 3.7 - main milestone Jan 9, 2024
@gsmet gsmet modified the milestones: 3.7 - main, 3.6.5 Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/picocli kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants