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

Codegen fails when command contains field with argGroup annotation (4.0.1) #777

Closed
eomeara opened this issue Jul 30, 2019 · 7 comments
Closed
Labels
theme: codegen An issue or change related to the picocli-codegen module type: bug 🐛
Milestone

Comments

@eomeara
Copy link

eomeara commented Jul 30, 2019

Sample argGroup code in documentation causes codegen to fail during gradle build.
Also don't know why warning is present.
Sample project attached.

build.gradle.kts

plugins {
    `java-library`
}

repositories {
    mavenLocal()
    maven {
        url = uri("http://repo.maven.apache.org/maven2")
    }
}

dependencies {
    implementation("info.picocli:picocli-spring-boot-starter:4.0.1")
    annotationProcessor("info.picocli:picocli-codegen:4.0.1")
}

MutuallyExclusiveOptionsDemo.java

package bug.codegen.ArgGroup;

import picocli.CommandLine.*;

@Command(name = "exclusivedemo")
public class MutuallyExclusiveOptionsDemo {

    @ArgGroup(exclusive = true, multiplicity = "1")
    Exclusive exclusive;

    static class Exclusive {
        @Option(names = "-a", required = true) int a;
        @Option(names = "-b", required = true) int b;
        @Option(names = "-c", required = true) int c;
    }
}

Gradle console output

.\gradlew clean build

> Task :compileJava FAILED
warning: Supported source version 'RELEASE_6' from annotation processor 'org.gradle.api.internal.tasks.compile.processing.TimeTrackingProcessor' less than -source '1.8'
C:\Users\auser\Documents\args-bug\src\main\java\bug\codegen\ArgGroup\MutuallyExclusiveOptionsDemo.java:9: error: @ArgGroups must be enclosed in a @Command or @ArgGroup-annotated element, but was bug.codegen.ArgGroup.MutuallyExclusiveOptionsDemo: MutuallyExclusiveOptionsDemo
    Exclusive exclusive;
              ^
Note: ReflectConfigGen writing to: CLASS_OUTPUT/META-INF/native-image/picocli-generated/reflect-config.json
Note: ResourceConfigGen writing to: CLASS_OUTPUT/META-INF/native-image/picocli-generated/resource-config.json
Note: ProxyConfigGen writing to: CLASS_OUTPUT/META-INF/native-image/picocli-generated/proxy-config.json
1 error
1 warning

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
2 actionable tasks: 1 executed, 1 up-to-date

args-bug.zip

@remkop
Copy link
Owner

remkop commented Jul 30, 2019

Thanks for reporting this!
This looks like a bug in the annotation processor. I’ll take a look.

@remkop
Copy link
Owner

remkop commented Aug 1, 2019

I was able to reproduce the problem. There are several issues with argument groups in the annotation processor. I am looking at how to address this.

About the warning: The picocli annotation processor is compiled with Java 6, and by default has a supported source version of RELEASE_6. Looking at this StackOverflow question, there may not much that can be done about it. I agree this is annoying.

remkop added a commit that referenced this issue Aug 1, 2019
@remkop remkop added this to the 4.0.2 milestone Aug 1, 2019
@remkop remkop added type: bug 🐛 theme: codegen An issue or change related to the picocli-codegen module labels Aug 1, 2019
@remkop
Copy link
Owner

remkop commented Aug 4, 2019

It took a while, but I pushed a fix for this issue to master.
It would be great if you can confirm.

I will add some more tests and hope to do a 4.0.2 release with this fix later this week.

remkop added a commit that referenced this issue Aug 5, 2019
@remkop remkop closed this as completed in 88de3e0 Aug 6, 2019
@remkop
Copy link
Owner

remkop commented Aug 6, 2019

Fixed in master.
@eomeara It would be great if you could confirm. The easiest way to do this is to check out the project in git, then run gradlew publishToMavenLocal on the command line. (Or gradlew -x check publishToMavenLocal to skip the tests.)

After that you can use the picocli-4.0.2-SNAPSHOT dependency in your project.

@eomeara
Copy link
Author

eomeara commented Aug 6, 2019

Will try to check this evening. Was on bank holiday weekend Saturday to Monday.

@eomeara
Copy link
Author

eomeara commented Aug 7, 2019

My build now succeeds and all tests pass. In future I intend to move my code to GraalVM, though not yet.
Using the annotation processor is my first step.
P.S. Thanks for a great library.

@remkop
Copy link
Owner

remkop commented Aug 7, 2019

Thank you for the confirmation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: codegen An issue or change related to the picocli-codegen module type: bug 🐛
Projects
None yet
Development

No branches or pull requests

2 participants