将构建从 Linux 移植到 Windows 的 Maven 问题

问题描述 投票:0回答:1

我正在将项目构建从 Linux 移植到 Windows。我的 pom.xml 的以下部分遇到问题

我更换了

  <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>

<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>

第一个在 linux 下工作,但在 windows 下失败,所以我想使用适当的 cmd.exe 命令。然而,由于找不到目录存在的文件而失败,因此我的假设是命令失败了。 我还尝试了带有适当参数的powershell命令Remove-Item,但这也失败了,我也尝试过更改参数顺序也没有成功。

maven maven-3
1个回答
0
投票

rm
是 Linux 可执行文件,但
rmdir
不是 Windows 可执行文件:它是命令。正确的可执行文件是
CMD
,其中
/c rmdir
作为前两个参数。然而,上面建议的
maven-antrun-plugin
maven-clean-plugin
是更好的选择,因为结果适用于 Linux 和 Windows。

© www.soinside.com 2019 - 2024. All rights reserved.