2

I use a specified property to create fileset:

<property name="cases" value="B.java,A.java,C.java" />
<fileset id="casesToBeRunning" dir="${src}" includes="${cases}" />

When casesToBeRunning created, I list the content of it:

<echo>Cases to be running: ${toString:casesToBeRunning}</echo>

it shows A.java,B.java,C.java which I'm not expected to.

I don't want Ant autosort for me, I need the original sort order of the property I defined to execute the cases orderly.

Anyone know how to handle this?

martin clayton
  • 76,436
  • 32
  • 213
  • 198
JerryCai
  • 1,663
  • 4
  • 21
  • 36

1 Answers1

4

Ant filesets don't retain order - as you've seen. The related filelist type does respect ordering, so you might use:

<filelist id="casesToBeRunning" dir="${src}" files="${cases}" />

Whether the order is respected will depend on what task you plan to use to process the files. Most core Ant tasks that accept a fileset will accept a filelist instead, so you should be ok with them. For non-core tasks it may not work.

(Note that before Ant 1.8.0 some tasks didn't respect the order when traversing a filelist - among them copy for example).

Johannes Weiss
  • 52,533
  • 16
  • 102
  • 136
martin clayton
  • 76,436
  • 32
  • 213
  • 198