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 annotation processor not working in Kotlin/GraalVM projects #1076

Closed
thombergs opened this issue Dec 24, 2022 · 5 comments
Closed

PicoCLI annotation processor not working in Kotlin/GraalVM projects #1076

thombergs opened this issue Dec 24, 2022 · 5 comments

Comments

@thombergs
Copy link

thombergs commented Dec 24, 2022

When I create a project with Kotlin, PicoCLI and GraalVM, PicoCLI's annotation processor isn't working. This annotation processor is responsible for creating the runtime hints for GraalVM. The effect is that when I run the native executable that is the result of ./gradlew nativeCompile, I get this error:

2022-12-25T07:12:09.568+11:00 ERROR 62436 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalStateException: Failed to execute CommandLineRunner
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:770) ~[demo:3.0.1]
        at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:751) ~[demo:3.0.1]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[demo:3.0.1]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[demo:3.0.1]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[demo:3.0.1]
        at com.example.demo.DemoApplicationKt.main(DemoApplication.kt:13) ~[demo:na]
Caused by: picocli.CommandLine$InitializationException: picocli.CommandLine$AutoHelpMixin@1d0da99b is not a command: it has no @Command, @Option, @Parameters or @Unmatched annotations
        at picocli.CommandLine$Model$CommandReflection.validateCommandSpec(CommandLine.java:11985) ~[na:na]
        at picocli.CommandLine$Model$CommandReflection.extractCommandSpec(CommandLine.java:11815) ~[na:na]
        at picocli.CommandLine$Model$CommandSpec.forAnnotatedObject(CommandLine.java:6388) ~[demo:4.7.0]
        at picocli.CommandLine$Model$CommandSpec.mixinStandardHelpOptions(CommandLine.java:7382) ~[demo:4.7.0]
        at picocli.CommandLine$Model$CommandReflection.extractCommandSpec(CommandLine.java:11810) ~[na:na]
        at picocli.CommandLine$Model$CommandSpec.forAnnotatedObject(CommandLine.java:6388) ~[demo:4.7.0]
        at picocli.CommandLine.<init>(CommandLine.java:230) ~[demo:4.7.0]
        at picocli.CommandLine.toCommandLine(CommandLine.java:3631) ~[demo:4.7.0]
        at picocli.CommandLine.access$16600(CommandLine.java:148) ~[demo:4.7.0]
        at picocli.CommandLine$Model$CommandReflection.initSubcommands(CommandLine.java:11840) ~[na:na]
        at picocli.CommandLine$Model$CommandReflection.extractCommandSpec(CommandLine.java:11806) ~[na:na]
        at picocli.CommandLine$Model$CommandSpec.forAnnotatedObject(CommandLine.java:6388) ~[demo:4.7.0]
        at picocli.CommandLine.<init>(CommandLine.java:230) ~[demo:4.7.0]
        at picocli.CommandLine.<init>(CommandLine.java:224) ~[demo:4.7.0]
        at com.example.demo.PicoCliRunner.run(PicoCliRunner.kt:17) ~[demo:na]
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:767) ~[demo:3.0.1]
        ... 5 common frames omitted

I don't know whether this is a general problem with annotation processing in Kotlin projects or if this is related to PicoCLI but I assume it's the former.

Here are reproducer projects:

To avoid having to add the runtime hints manually, I configured kapt to activate the annotation processor:

plugins {
    id 'org.jetbrains.kotlin.kapt' version '1.7.21'
}

dependencies {
    kapt 'info.picocli:picocli-codegen:4.7.0'
}

kapt {
    arguments {
        arg("project", "${project.group}/${project.name}")
    }
}

Note that kapt is in maintenance mode and superseded by KSP. I didn't take the time to look into KSP, though, as I didn't find good docs when I looked.

Kotlin/GraalVM projects generated by Initializt that need annotation processing should probably configure KSP/kapt to work properly?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 24, 2022
@wilkinsona wilkinsona transferred this issue from spring-io/initializr Jan 3, 2023
@wilkinsona
Copy link
Contributor

Relates to #1060.

@bclozel
Copy link
Member

bclozel commented Jan 3, 2023

I've just discussed that with @sdeleuze and it seems that:

@yogeshVU
Copy link

@bclozel what is the interim solution for this? how does one configure the KAPT plugin as suggested?

@bclozel
Copy link
Member

bclozel commented Jan 14, 2023

@yogeshVU I think the Picocli docs cover this: https://picocli.info/#_enabling_the_annotation_processor

@mhalbritter
Copy link
Contributor

mhalbritter commented May 27, 2024

As the picocli Spring Boot starter doesn't support Boot 3.2.x or 3.3.x, we have removed it from the site. This issue is obsolete now.

@mhalbritter mhalbritter closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2024
@mhalbritter mhalbritter added status: declined and removed status: waiting-for-triage An issue we've not yet triaged labels May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants