-
Notifications
You must be signed in to change notification settings - Fork 429
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
How to get the version automatically from Gradle or Maven? #757
Comments
Would this meet your needs: https://github.com/remkop/picocli/blob/master/picocli-examples/src/main/java/picocli/examples/VersionProviderDemo1.java This is a |
@remkop Thank you for your help! This solution looks interesting. We are using something similar with GIT commit details too, for webapps where this info also needs to be displayed on pages. Would it be possible to skip the entire |
@aadrian That may be possible but not sure how. If you find a way, please share it so that the whole picocli community can benefit! |
@remkop This https://picocli.info/#_dynamic_version_information looks interesting, especially the Meta-Inf https://github.com/remkop/picocli/blob/master/picocli-examples/src/main/java/picocli/examples/VersionProviderDemo2.java example, since a correctly configured application will always generate that file with the version number. Unfortunately that example just picks the first Meta-Inf that has a version and a title from the classpath. I'm not sure how to enforce that the 'name' is unique among all JARs (because 3rd party dependencies). |
No, that statement is incorrect. The example loops over all manifests in the classpath, until it finds (see the An application could use a different filter, or a similar filter but select a different implementation title. |
Yes, but the
Indeed, that's a good workaround. A "marker" property different than |
I see what you’re saying now: Could picocli not include a version provider implementation that looks for a custom property in the manifest and prints version information from the first jar in the classpath that has a manifest with that custom property? Perhaps I was focused too much on the built-in attributes like Actually all my questions can be answered with the custom property you proposed. The value of the property could be the value that should be printed, and this could be multi-line by embedding
Picocli could include a So the build should ensure the jar includes this property in its manifest. The documentation should clarify how to accomplish that with popular build tools. Do you think you’ll be able to provide a pull request for this? |
This issue gave me some hints for how to store the Gradle version into my application Jar. Thanks! Application is a Groovy CLI compiled by gradle and distributed as a java uber jar. |
It would be really great if Picocli would provide such a provider by default. I'll may take a stab at this. |
@helpermethod I am not sure if the library should include such a version provider implementation. This ticket #1663 shows how simple the application code for this can be. |
@remkop Makes Sense! My point is that setting the version number at build time is such a common problem that it probably would make sense to solve this once. But showing an example would be okay I guess. |
How to get the version automatically? (from Gradle and Maven)?
This version information is already defined in any Gradle or Maven build file in the
version
property.Would be really helpful if this property would be available in the annotation, to be able to have something like e.g.:
Thank you
The text was updated successfully, but these errors were encountered: