-
Notifications
You must be signed in to change notification settings - Fork 88
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
Add defaultValue
for all boolean Mojo parameters defaulting to false
#219
base: master
Are you sure you want to change the base?
Conversation
Otherwise documentation will not mention the default, which will be confusing for the user.
src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
Outdated
Show resolved
Hide resolved
defaultValue
for all boolean Mojo parametersdefaultValue
for all boolean Mojo parameters defaulting to false
Open question: fix pluginxml generation instead of fixing all mojo since it is valid to use the default value for primitives? |
That might indeed be a better solution. Can there be cases though were a parameter has a different default value, which is not set with For example, if the constructor of a Mojo assigns a value to a field. Does that act as default value then? |
@Marcono1234 it is possible but will not be in the documentation (requires textual description) but guess the good practise stays to write the less so if default is automatic doc should be aware of it somehow, either ensuring we inject the default for primitives in plugin.xml or let the doc handle it IMHO. |
But how do you propose this should be done without being error-prone? Or do you propose to not only improve how the documentation is generated, but also how Maven determines the Another case which comes to my mind is: @Parameter
boolean param = true; Will the documentation plugin be aware that the default value is Having the documentation plugin just document So yes, maybe this issue could be solved generally for all plugins by doing a change in Maven Plugin Plugin (?). But to me it seems the solution is not simple (if possible at all). So would you mind accepting this pull request here the way it is for now? |
The 2 simple options:
(I prefer 1 since it will work for all consumers but 2 works for "us") The inline init case is not supposed to work and it is also hard since init can be conditional (env for ex) so let's ignore coded init and just stick to implicit defaults. |
But does it work currently, and are plugins relying on this? Because if Maven Plugin Plugin is changed to pick a different default value in the future in those cases, or if it starts documenting a default value which is not actually the default value, then I doubt that those changes will be made. Either way, I think this is getting a bit off-topic. Would you mind merging the changes here? If you want the Maven Plugin Plugin to change, could you or someone else please drive those changes, because I am neither familiar enough with Maven internals nor Maven plugin development, and I personally also doubt that such a change would be worth it given the compatibility risks. |
Some plugings use it but it since it is not static we cant handle it automatically. I'd prefer to fix the doc and not pollute shade plugin with unexpected code if possible but just my 2cts. |
@rmannibucau, I had a look at this again, but I still don't see how Maven Plugin Plugin or similar could be enhanced to infer the default value. And suddenly determining a different default value would break existing plugins. See my earlier comment above: #219 (comment) This pattern of assigning the default value using the field initializer is not that uncommon. Examples: |
@slachiewicz, would you mind merging these changes? These changes hopefully help users now (respectively the next Shade Plugin release), whereas some general Maven Plugin Plugin changes (in case they are ever performed, see my concerns above) might only happen after months or years. |
Currently the Mojo documentation does not mention the default for these parameters, which will be confusing for the user. Have for example a look at the current https://maven.apache.org/plugins/maven-shade-plugin/shade-mojo.html documentation; you will see that for all the changed parameters no default value is currently documented. So it is not clear whether these parameters apply by default.
Please let me know if I forget to consider something and this change has any undesired side effects.
Following this checklist to help us incorporate your
contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
[MSHADE-XXX] - Fixes bug in ApproximateQuantiles
,where you replace
MSHADE-XXX
with the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean verify
to make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
mvn -Prun-its clean verify
).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.