-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
default cli-app project doesn't work with GraalVM because of PicoCLI #739
Comments
Picoli includes its own Graal integration, a tutorial is here https://picocli.info/picocli-on-graalvm.html @remkop anything we can do to make Micronaut + Graal work more out of the box? Like modifications to the profile etc. |
@graemerocher Some early thoughts:
Question: will the I guess there should be a separate |
FYI I'm working on an annotation processor for picocli that would allow things like generating the |
@remkop I think it may make sense to use Micronaut's visitor API to achieve this without needing reflection and the classes themselves on the class path (just the source code needed). Also it would work for both Groovy and Java (instead of limiting yourself to just Java and the annotation processing API). See for example https://github.com/micronaut-projects/micronaut-core/blob/master/configurations/openapi/src/main/java/io/micronaut/openapi/visitor/OpenApiApplicationVisitor.java |
Ok, that is certainly interesting! Either way, both the Micronaut visitor API and standard Java annotation processors will need parts of the picocli internal model to become part of the picocli public API. Figuring out these API changes is part of the work I'm doing now in the picocli annotation processor. It's important to get this right so I want to take my time with it. As an interim solution, I could release |
My previous comment is wrong/incomplete: It is also possible to re-implement the functionality that I don't have time to do this now but I'd be happy to answer questions if anyone wants to contribute such a tool to Micronaut. |
Update: The @graemerocher I believe this goes a long way towards what you are looking for in terms of tooling to make Micronaut + Graal work more out of the box. What is left is documentation:
|
@picaron If you are using this and if you have any feedback on how to improve this further, please give a shout. |
Thanks @remkop , looks good |
@graemerocher Please let me know if #760 or #761 need tweaking before they can be merged. |
@remkop looks good, thanks |
@remkop actually if you can rebsumit the PRs to the 1.0.x branch that would help |
I did it from the User Guide web page "Improve this doc", not from an IDE. Not sure what branch that targets. Is it possible to cherry-pick the commit onto other branches after accepting the PR? I don't have my environment set up... |
@remkop ok no worries, will do manual merge |
@graemerocher I saw the PRs got merged, thanks! However, I don't see the changes yet in the online user manual (latest version nor the snapshot version), is that expected? |
I believe this was resolved, if any changes let us know |
Hi,
This seems to be an error with the reflective access of PicoCLI. dependencies {
compile 'info.picocli:picocli:4.0.0-alpha-3'
generateConfig 'info.picocli:picocli-codegen:4.0.0-alpha-3'
}
task(generateGraalReflectionConfig, dependsOn: 'classes', type: JavaExec) {
main = 'picocli.codegen.aot.graalvm.ReflectionConfigGenerator'
classpath = configurations.generateConfig + sourceSets.main.runtimeClasspath
def outputFile = "${buildDir}/resources/main/META-INF/native-image/${project.group}/${project.name}/reflect-config.json"
args = ["--output=$outputFile", 'example.GitStarCommand']
}
assemble.dependsOn generateGraalReflectionConfig which resulted in this error message:
Help would be appreciated, and I would also volunteer to update the docs accordingly. |
@t-buss The (Something like this:)
|
@t-buss One way to fix the problem is to add the Alternatively use the same version of picocli and |
@t-buss Did this solve the problem? |
@remkop We managed to resolve it and adding the dependency to the RUN native-image --no-server -cp build/libs/git-star-*.jar -H:ReflectionConfigurationFiles=build/resources/main/META-INF/native-image/reflect-config.json example.GitStarCommand |
@t-buss Thanks for the update. I will take a look. |
@t-buss Picocli 4.0.0-beta-1b has an annotation processor that includes the refect.config in your jar, so |
I tried building a native image for a blank cli-app project generated with the
mn
command and it doesn't work at runtime because of the way PicoCLI worksI was using micronaut
1.0.0.RC2
and graalvm1.0.0-rc7-graal
(both installed with SDKMan)I had to switch to the Clikt library (for Kotlin) and then I was able to generate a native-image for my cli-app
The text was updated successfully, but these errors were encountered: