Skip to content
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

Empty argument tag should add empty string instead of null #150

Merged
merged 2 commits into from Aug 19, 2020

Conversation

Anders-E
Copy link
Contributor

Created new PR since I could not update the old one (#133, issue #132 ) due to the fork being deleted.

An empty argument tag such as:

<argument></argument>

Now adds an empty string instead of null to String[] args.

Copy link

@ctubbsii ctubbsii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this and it works as expected. It preserves an empty argument.

My test case was (pom.xml):

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>none</groupId>
  <artifactId>tester</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>pom</packaging>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.0.0-SNAPSHOT</version>
        <executions>
          <execution>
            <id>testitnow</id>
            <phase>validate</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>./exec-test-script.sh</executable>
              <arguments>
                <argument>a</argument>
                <argument>b</argument>
                <argument />
                <argument>d</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

The script, exec-test-script.sh contained:

#! /usr/bin/bash
echo Number of args is "${#@}"
for x in "$@"; do
  echo " ->$x<-"
done

I verified that the third argument was omitted before the PR, and that it was included as an empty argument after the PR.


However, there still doesn't appear to be any way to preserve whitespace, if you want an argument consisting of a space, as in:

  <configuration>
    <executable>tr</executable>
    <arguments>
      <argument> </argument>
      <argument>_</argument>
      <argument>&lt;filename</argument>
    </arguments>
  </configuration>

This might be an limit of Maven itself. It seems there may have been a regression of: https://issues.apache.org/jira/browse/MNG-5380

@Anders-E
Copy link
Contributor Author

Noticed this was still open while checking my PRs. Should this be merged? @ctubbsii

@ctubbsii
Copy link

Noticed this was still open while checking my PRs. Should this be merged? @ctubbsii

I think it should, but I don't have commit access to this project.

@Anders-E
Copy link
Contributor Author

@ctubbsii oh sorry, I just figured you did for some reason.

@olamy would this PR be of interest or should I close it?

@ctubbsii
Copy link

@ctubbsii oh sorry, I just figured you did for some reason.

No big deal. It's probably because GitHub says I "approved" it by giving a code review.

Pro tip: the gray checkmark next to an approval indicates the person submitted an approval as a non-committer performing a code review. A green checkmark would be displayed (like those at the bottom, by the status checks), if the reviewer had write access. It's a very subtle difference. Also the green checkmarks at the bottom can often be misinterpreted as a code review checkmark... I wish they used a different color for those.

@Anders-E
Copy link
Contributor Author

Pro tip: the gray checkmark next to an approval indicates the person submitted an approval as a non-committer performing a code review. A green checkmark would be displayed (like those at the bottom, by the status checks), if the reviewer had write access. It's a very subtle difference. Also the green checkmarks at the bottom can often be misinterpreted as a code review checkmark... I wish they used a different color for those.

Ah I've never noticed that before, thank you for the tip!

@olamy olamy added the bug label Aug 19, 2020
@olamy olamy merged commit d0e13ba into mojohaus:master Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants