文件集目录未正确排除

发布于 2025-01-11 16:26:41 字数 1789 浏览 0 评论 0原文

学习 Ant - 我试图排除某个目录下的所有文件:

<fileset dir="${testclasses.dir}" id="test.files">
  <exclude name="**/directory-to-exclude/*.class"/>
</fileset>

并确保我正确排除,我打印出该文件集下的所有类,如下所示:

<path id="updated.test.classes.path">
  <fileset dir="${testclasses.dir}"/>
</path>

<pathconvert pathsep="${line.separator}|   |-- "
             property="echo.path.compile"
             refid="updated.test.classes.path">
</pathconvert>
<echo message="Printing updated class path: ${echo.path.compile}"/>

但我仍然看到:

     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$$anon$1.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$$typecreator1$1.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$Complex$.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$Complex.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$Deep$.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$Deep.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$LessDeep$.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$LessDeep.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$StrToTime.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$Struct$.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$Struct.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass.class

为什么会发生这种情况?

Learning Ant - I'm trying to exclude all files under a certain directory with:

<fileset dir="${testclasses.dir}" id="test.files">
  <exclude name="**/directory-to-exclude/*.class"/>
</fileset>

and to make sure I excluded correctly, I'm printing out all the classes under that fileset like so:

<path id="updated.test.classes.path">
  <fileset dir="${testclasses.dir}"/>
</path>

<pathconvert pathsep="${line.separator}|   |-- "
             property="echo.path.compile"
             refid="updated.test.classes.path">
</pathconvert>
<echo message="Printing updated class path: ${echo.path.compile}"/>

Yet I still see:

     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$anon$1.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$typecreator1$1.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$Complex$.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$Complex.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$Deep$.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$Deep.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$LessDeep$.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$LessDeep.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$StrToTime.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$Struct$.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass$Struct.class
     [echo] |   |-- /path/to/testfiles/directory-to-exclude/SomeTestClass.class

why is this happening?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苏别ゝ 2025-01-18 16:26:41

您没有使用预定义的文件集,您需要:

<path id="updated.test.classes.path">
  <fileset refid="test.files"/>
</path>

注意 refid= 参数,该参数使用您通过排除定义的文件集。

实际代码将仅包含所有文件。

<fileset dir="${testclasses.dir}"/>

正如您所观察到的,路径任务中的

You aren't using the fileset you pre-defined, you want:

<path id="updated.test.classes.path">
  <fileset refid="test.files"/>
</path>

Note the refid= parameter, which makes use of the fileset you defined with the exclusion.

Your actual code

<fileset dir="${testclasses.dir}"/>

in the path task will simply include all files, as you observed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文