蚂蚁替换任务-Windows vs Mac

发布于 2025-02-07 16:44:41 字数 1087 浏览 1 评论 0原文

我正在尝试使用ANT的替换任务来修改XHTML文件,但是在MacOS上构建时遇到了问题。我已经通过以下最小设置复制了问题。

我有以下测试文本文件

    <div>
      <p>replace this</p>
    </div>

和以下build.xml文件,

<?xml version="1.0" encoding="UTF-8"?>
<project name="test.ant.replace" default="main">

    <target name="main">
        <replace file="test.txt">
            <replacetoken><![CDATA[<div>
      <p>replace this</p>
    </div>]]></replacetoken>
            <replacevalue><![CDATA[<div>
      <p>with this</p>
    </div>]]></replacevalue>
        </replace>
    </target>

</project>

将测试文件格式为CRLF。 这是从提供的zip文件中解开包装的,因此我想以提供的格式保存)。

  • (实际上, 替换发生。
  • 当我在MacOS上运行示例时,它会做到 不是。
  • 如果我将测试文件格式更改为LF,则可以在MacOS上使用 但不在窗户上。

为了允许两个平台上的开发人员运行构建,这意味着我无法通过FIXCRLF任务更改输入测试文件的线路结尾。

q。如何将我的替换任务的替换值更改为在两个平台上工作?

I'm trying to use Ant's replace task to modify an xhtml file but am having a problem when building on MacOS. I have replicated the issue with the following minimal setup.

I have the following test text file

    <div>
      <p>replace this</p>
    </div>

and the following build.xml file

<?xml version="1.0" encoding="UTF-8"?>
<project name="test.ant.replace" default="main">

    <target name="main">
        <replace file="test.txt">
            <replacetoken><![CDATA[<div>
      <p>replace this</p>
    </div>]]></replacetoken>
            <replacevalue><![CDATA[<div>
      <p>with this</p>
    </div>]]></replacevalue>
        </replace>
    </target>

</project>

The test file is formatted as CRLF. (In practice this is unpacked from a provided zip file so I'd like to keep it in the provided format)

  • When I run the example using ant -v on Windows, the build works and
    the replacement takes place.
  • When I run the example on MacOS it does
    not.
  • If I change the test file format to LF, then it works on MacOS
    but not on Windows.

To allow developers on both platforms to run the build this implies I can't change the input test file's line endings via the FixCRLF task.

Q. How can I change my replace task's replacetoken value to work on both platforms?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文