I am porting a project build from linux to windows. I am running into problems with the following piece of my pom.xml
I replaced
<execution>
<id>rm -rf node_modules/</id>
<goals>
<goal>exec</goal>
</goals>
<phase>initialize</phase>
<configuration>
<executable>rm</executable>
<arguments>
<argument>-fr</argument>
<argument>node_modules/</argument>
</arguments>
</configuration>
</execution>
With
<execution>
<id>rm -rf node_modules/</id>
<goals>
<goal>exec</goal>
</goals>
<phase>initialize</phase>
<configuration>
<executable>rmdir</executable>
<arguments>
<argument>.\node_modules\</argument>
<argument>/S</argument>
<argument>/Q</argument>
</arguments>
</configuration>
</execution>
The first works under linux but fails under windows, so I figured use the appropriate cmd.exe commands. This however is failing with a file not found the directory exists so my assumption is that it is the command that is failing. I also tried the powershell command Remove-Item with appropriate arguments this also failed, I have also tried changing the argument order also a no go.
rm
is a Linux executable, but rmdir
is not a Windows executable: it is a command. The correct executable is CMD
with /c rmdir
as the first two arguments. However the maven-antrun-plugin
suggested above and the maven-clean-plugin
are better choices because the result will work both with Linux and Windows.