apache / apache/maven

[MNG-6858] Need a way to skip empty-string arguments

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

Description

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

I have a bash script that sets a sometimes-empty variable as follows:

 

```java
if [ "${ANDROID}" = "true" ]; then
  MAYBE_ANDROID_FLAG=-Pandroid
else
  MAYBE_ANDROID_FLAG=
fi
```

 

It's used like so:

 

```java
mvn ${MAYBE_ANDROID_FLAG} clean compile jacoco:instrument jacoco:prepare-agent test jacoco:restore-instrumented-classes jacoco:report -e -B}}
```

 

Shell-scripting best practices dictate that ${MAYBE_ANDROID_FLAG} above should be in double quotes, but when I do that, I get 'Unknown lifecycle phase ""'. For it to be possible to follow best practices, then, we need a way to make Maven skip over command-line arguments that are empty strings.

---

**Affects:** 3.6.1

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.