apache / apache/maven

[MNG-6434] Cannot specify empty string for configuration value

Open
#7,420 10 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
5.3k
Forks
3.1k
Avg merge
20h 42m
Merged PRs (30d)
297

Description

**[Chris Egerton](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=chrisegerton)** opened **[MNG-6434](https://issues.apache.org/jira/browse/MNG-6434?redirect=false)** and commented

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 = "foo.bar", 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.":

``
`  `
``

or

``
`  `
``

 

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 value?

---

**Affects:** 3.5.4

**Issue Links:**
- [JCRVLT-651](https://issues.apache.org/jira/browse/JCRVLT-651) validate-package: Allow to exclude main artifact
(_**"causes"**_)

0 votes, 6 watchers

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.