路径中的蚂蚁大写与小写字符

ant uppercase vs lowercase characters in path

我有一个 ant 目标,可以将文件从一个位置复制到另一个位置,假设它在 build.xml 中定义为:

 ${project}/some-component-ABC/lib/whatever.jar

但在文件系统上实际路径是

 ${project}/some-component-abc/lib/whatever.jar

fliesystem 上的 some-component-abc 中没有大写 ABC...

此路径将在 Windows (7) 中解析,但不会在 Linux?

中解析

为什么?

我会想办法用它做什么,只是想知道为什么功能不同的背景。

根据以下文章:https://ubuntuforums.org/showthread.php?t=1227827 Linux是用C写的,区分大小写。它可以加快排序速度。

Ant 不会对路径做任何花哨的事情——它只是委托给底层文件系统。 Windows' 文件系统不区分大小写,而我能想到的任何 linux 文件系统都是。因此,在 windows 中,some-component-abcsome-component-ABC 是同一个目录,而在 linux 中则不是。

正如其他人所提到的,在大多数情况下,Ant 只是存储所有内容的字符串,并在实际执行文件系统操作时依赖于 OS 的文件系统,因此您将 运行在 Linux 与 Windows.

中的 运行ning 脚本时,会出现这样的差异

但是,Ant 确实有处理类路径字符串的任务,这些任务可用于在使用文件之前整理对文件的引用。这是一个例子:

~/test $ ls -1
build.xml
FILE

build.xml:

<project>
    <pathconvert property="file">
        <fileset dir="${basedir}" includes="file" casesensitive="false" />
    </pathconvert>

    <echo message="${file}" />
</project>

输出:

[echo] /home/me/test/FILE

替代方法(将 return 一个相对于文件集的 dir 属性的类似路径的字符串):

<project>
    <fileset dir="${basedir}" includes="file" casesensitive="false" id="filepath" />

    <property name="file" refid="filepath" />

    <echo message="${file}" />
</project>

输出:

 [echo] FILE