如何在Ant concat中保留文件顺序?
带有fileset&includesfile的简单concat产生相当"随机"的顺序,因为订单无法保证:
<concat destfile="C:/targetdir/concatenated.file">
<fileset dir="C:/sourcedir/">
<includesfile name="C:/targetdir/includes.file" />
</fileset>
</concat>
Run Code Online (Sandbox Code Playgroud)
我需要的是以特定顺序连接文件列在包含文件中.
到目前为止,我已经找到了资源列表,它应该保留顺序,但我似乎无法用它生成任何连接文件.:/
<concat destfile="C:/targetdir/concatenated.file">
<resourcelist>
<file file="C:/targetdir/includes.file"/>
<filterchain>
<striplinecomments>
<comment value="#"/>
</striplinecomments>
<prefixlines prefix="C:/sourcedir/"/>
</filterchain>
</resourcelist>
</concat>
Run Code Online (Sandbox Code Playgroud)
另外,资源列表似乎无法处理像
LibraryX/A/Stuff/Morestuff/*
Run Code Online (Sandbox Code Playgroud)
相反,该行只会产生"....../Morestuff/*不存在".-错误
包含文件包含相对路径列表:
LibraryX/A/Stuff/FileA.txt
LibraryX/A/Stuff/FileB.txt
LibraryX/A/Stuff/FileC.txt
LibraryX/A/Stuff/FileY.txt
Run Code Online (Sandbox Code Playgroud)
Ada*_*m C 13
我能够很容易地获得一个文件列表:
<concat destfile="C:/targetdir/concatenated.file">
<filelist dir="C:/sourcedir/">
<file name="i.txt" />
<file name="n.txt" />
<file name="o.txt" />
<file name="r.txt" />
<file name="d.txt" />
<file name="e.txt" />
<file name="r.txt" />
</filelist>
</concat>
Run Code Online (Sandbox Code Playgroud)
希望有所帮助!
如果您使用的是Ant 1.7+,则可以使用sort命令
<concat destfile="C:/targetdir/concatenated.file">
<sort>
<fileset dir="C:/sourcedir/">
<include name="C:/targetdir/*.file" />
</fileset>
</sort>
</concat>
Run Code Online (Sandbox Code Playgroud)
你可以在这里找到排序文档
[在 Ant 1.8.2+ 上] 您还可以通过排序传递文件集,并按文件名排序,如下所示:
<concat destfile="./${dir.publish}/${dir.js}/b.main-${build.number}.debug.js">
<sort xmlns:rcmp="antlib:org.apache.tools.ant.types.resources.comparators">
<fileset dir="./${dir.publish}/">
<include name="**/${dir.js.main}/**/*.js"/>
<exclude name="**/${dir.js.main}/**/*.min.js"/>
</fileset>
<rcmp:name />
</sort>
</concat>
Run Code Online (Sandbox Code Playgroud)
有几点需要注意:
更新:如果您需要手动指定顺序,还有另一种选择:
<!-- create a ordered list of all the build files so that CIAPI & CIAPI.widget are built first
(can't find a smarter way to do this, since ant filesets are unordered) -->
<fileset id="a" dir="."><include name="CIAPI/build.project.xml"/></fileset>
<fileset id="b" dir="."><include name="CIAPI.widget/build.project.xml"/></fileset>
<fileset id="c" dir=".">
<include name="**/build.project.xml"/>
<exclude name="CIAPI/build.project.xml" />
<exclude name="CIAPI.widget/build.project.xml" />
</fileset>
<union id="all_build_files">
<fileset refid="a"/>
<fileset refid="b"/>
<fileset refid="c"/>
</union>
Run Code Online (Sandbox Code Playgroud)
丑陋,但是,呃,这是蚂蚁?
| 归档时间: |
|
| 查看次数: |
7467 次 |
| 最近记录: |