maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Egerton (JIRA)" <>
Subject [jira] [Commented] (MNG-6434) Cannot specify empty string for configuration value
Date Wed, 27 Jun 2018 19:34:00 GMT


Chris Egerton commented on MNG-6434:

Thanks for your help! However, the issue isn't that whitespace-only values can't be specified,
it's that empty values can't be specified ("" vs " "). And, beneath that, it's that there's
no good way at the moment for a user to override a default value for a configuration with
something that says "I know this has a default value but I really don't want it included". We
could just recommend a value for the configuration and remove the defaults altogether, but
that would make it harder on our users and be a non-backwards-compatible change that we'd
like to avoid if possible.

Trying with {{xml:space="preserve"}} and values of " " and "" still resulted in the default
value being used for the parameter.

> Cannot specify empty string for configuration value
> ---------------------------------------------------
>                 Key: MNG-6434
>                 URL:
>             Project: Maven
>          Issue Type: Bug
>          Components: Plugin API
>    Affects Versions: 3.5.4
>            Reporter: Chris Egerton
>            Priority: Major
> We have a MOJO class that involves several user-configured parameters. Some of these
parameters have default values that we'd like to use in the event that the user doesn't specify
a value for them; however, we'd also like the user to be able to explicitly specify that the
parameter should _not_ have a value. The approach we wanted to take was to specify default
values in the parameter's annotation:
> {{@Parameter(property = "", defaultValue = "${project.scm.url}")}}
> {{private String foo;}}
> And then detect empty strings as the user's way of saying "I know there's a default value
for this parameter but I'm sure that I'd actually like it to be empty anyways.":
> {{<configuration>}}
> {{  <foo></foo>}}
> {{</configuration>}}
> or
> {{<configuration>}}
> {{  <foo />}}
> {{</configuration>}}
> However, there's been some trouble as we haven't found a way yet to distinguish between
an intentionally-empty string and one that hasn't been specified at all; the value for foo
is always null regardless.
> Is there a friendly and/or intuitive way for the user to pass an empty string as a parameter

This message was sent by Atlassian JIRA

View raw message