Empty argument tag should add empty string instead of null#150
Conversation
There was a problem hiding this comment.
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<-"
doneI 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><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
|
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. |
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. |
Ah I've never noticed that before, thank you for the tip! |
|
I wonder if Windows performs differently in this case. See apache/opendal#6059 (comment) We have: <properties>
<cargo-build.target/>
</properties>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>${exec-maven-plugin.version}</version>
<executions>
<execution>
<id>compile-native-code</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>python3</executable>
<arguments>
<argument>${project.basedir}/tools/build.py</argument>
<argument>--target</argument>
<argument>${cargo-build.target}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>This works on my Linux and macOS platform, but seems when running with |
|
@tisonkun please create new issue, this one is closed 😄 |
|
@slawekjaranowski Yes and sorry I'm a bit lazy just now - here it is: #471 |
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:
Now adds an empty string instead of
nulltoString[] args.