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

Can't exec mkdir -p target/directory in 3.1.0 #323

Closed
josephlbarnett opened this issue Jul 19, 2022 · 4 comments · Fixed by #324
Closed

Can't exec mkdir -p target/directory in 3.1.0 #323

josephlbarnett opened this issue Jul 19, 2022 · 4 comments · Fixed by #324
Assignees

Comments

@josephlbarnett
Copy link

consider the following pom:

<?xml version="1.0" encoding="UTF-8"?>
<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>com.joe.test</groupId>
    <artifactId>exec</artifactId>

    <version>1.0-SNAPSHOT</version>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>mkdirs</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <executable>mkdir</executable>
                            <arguments>
                                    <argument>-p</argument>
                                    <argument>dist/emails</argument>
                            </arguments>
                            <skip>${skip.tests}</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

This creates the dist/emails directory in 3.0.0, but fails in 3.1.0 with:

[DEBUG] Executing command line: [mkdir, -p]
mkdir: missing operand
Try 'mkdir --help' for more information.
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)

it works if using --parents instead of -p as an argument to mkdir -- I believe this is introduced by #172 but was intended to be introduced in #55?

@josephlbarnett josephlbarnett changed the title Can't invoke mkdir -p target/directory in 3.1.0 Can't exec mkdir -p target/directory in 3.1.0 Jul 19, 2022
@janhicken
Copy link

I'm also having a configuration with a -p argument and it broke with version 3.1.0. Using the long form of it works as a workaround.

@bmarwell
Copy link
Contributor

Interesting. Will look into it.

bmarwell added a commit that referenced this issue Jul 21, 2022
@bmarwell
Copy link
Contributor

bmarwell commented Jul 21, 2022

Got it. The problem is:

https://github.com/mojohaus/exec-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/exec/ExecMojo.java#L733-L736

Workaround for now is:

-Dexec.longModulepath=false or configuration <longModulepath>false</longModulepath>.

Or use <argument>--parents</argument>, but this will not work on AIX, BSD, MacOS etc.: https://www.freebsd.org/cgi/man.cgi?query=mkdir&sektion=1&format=html and https://ss64.com/osx/mkdir.html

bmarwell added a commit that referenced this issue Jul 26, 2022
bmarwell added a commit that referenced this issue Jul 26, 2022
bmarwell added a commit that referenced this issue Jul 26, 2022
- added two ITs to check true/false behaviour of the new parameter.
bmarwell added a commit that referenced this issue Jul 27, 2022
- added two ITs to check true/false behaviour of the new parameter.
- removed dead code
bmarwell added a commit that referenced this issue Jul 27, 2022
- added two ITs to check true/false behaviour of the new parameter.
- removed dead code
@bmarwell bmarwell self-assigned this Jul 27, 2022
@dwhitejazz
Copy link

Just ran into this issue and glad to find it reported here. Is there a scheduled update? For now the workaround is fine.

dongjoon-hyun pushed a commit to apache/spark that referenced this issue Apr 16, 2024
### What changes were proposed in this pull request?

### Why are the changes needed?
- `exec-maven-plugin` from `3.1.0` to `3.2.0`
https://github.com/mojohaus/exec-maven-plugin/releases/tag/3.2.0
https://github.com/mojohaus/exec-maven-plugin/releases/tag/3.1.1
Bug Fixes:
1.Fix mojohaus/exec-maven-plugin#158 - Fix non ascii character handling (mojohaus/exec-maven-plugin#372)
2.[mojohaus/exec-maven-plugin#323] exec arguments missing (mojohaus/exec-maven-plugin#324)

- `build-helper-maven-plugin` from `3.4.0` to `3.5.0`
https://github.com/mojohaus/build-helper-maven-plugin/releases/tag/3.5.0

- `maven-compiler-plugin` from `3.12.1` to `3.13.0`
https://github.com/apache/maven-compiler-plugin/releases/tag/maven-compiler-plugin-3.13.0

- `maven-jar-plugin` from `3.3.0` to `3.4.0`
https://github.com/apache/maven-jar-plugin/releases/tag/maven-jar-plugin-3.4.0
[[MJAR-62]](https://issues.apache.org/jira/browse/MJAR-62) - Set Build-Jdk according to used toolchain (apache/maven-jar-plugin#73)

- `maven-source-plugin` from `3.3.0` to `3.3.1`
https://github.com/apache/maven-source-plugin/releases/tag/maven-source-plugin-3.3.1

- `maven-assembly-plugin` from `3.6.0` to `3.7.1`
https://github.com/apache/maven-assembly-plugin/releases/tag/maven-assembly-plugin-3.7.1
https://github.com/apache/maven-assembly-plugin/releases/tag/maven-assembly-plugin-3.7.0
Bug Fixes:
1.[[MASSEMBLY-967](https://issues.apache.org/jira/browse/MASSEMBLY-967)] - maven-assembly-plugin doesn't add target/class artifacts in generated jarfat but META-INF/MANIFEST.MF seems to be correct
2.[[MASSEMBLY-994](https://issues.apache.org/jira/browse/MASSEMBLY-994)] - Items from unpacked dependency are not refreshed
3.[[MASSEMBLY-998](https://issues.apache.org/jira/browse/MASSEMBLY-998)] - Transitive dependencies are not properly excluded as of 3.1.1
4.[[MASSEMBLY-1008](https://issues.apache.org/jira/browse/MASSEMBLY-1008)] - Assembly plugin handles scopes wrongly
5.[[MASSEMBLY-1020](https://issues.apache.org/jira/browse/MASSEMBLY-1020)] - Cannot invoke "java.io.File.isFile()" because "this.inputFile" is null
6.[[MASSEMBLY-1021](https://issues.apache.org/jira/browse/MASSEMBLY-1021)] - Nullpointer in assembly:single when upgrading to 3.7.0
7.[[MASSEMBLY-1022](https://issues.apache.org/jira/browse/MASSEMBLY-1022)] - Unresolved artifacts should be not processed

- `cyclonedx-maven-plugin` from `2.7.9` to `2.8.0`
https://github.com/CycloneDX/cyclonedx-maven-plugin/releases/tag/cyclonedx-maven-plugin-2.8.0
https://github.com/CycloneDX/cyclonedx-maven-plugin/releases/tag/cyclonedx-maven-plugin-2.7.11
https://github.com/CycloneDX/cyclonedx-maven-plugin/releases/tag/cyclonedx-maven-plugin-2.7.10
Bug Fixes:
1.check if configured schemaVersion is supported (CycloneDX/cyclonedx-maven-plugin#479)
2.ignore bomGenerator.generate() call (CycloneDX/cyclonedx-maven-plugin#376)

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Pass GA.

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes #46043 from panbingkun/update_maven_plugins.

Authored-by: panbingkun <panbingkun@baidu.com>
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants