带有绝对路径的HTML 5 ant脚本

带有绝对路径的HTML 5 ant脚本,ant,html5boilerplate,Ant,Html5boilerplate,我正在使用HTML5和ant构建脚本,我正在尝试将其集成到我现有的平台中,我所有的css和js文件都使用绝对路径。例如: <!-- scripts concatenated and minified via build script --> <script type="text/javascript" src="/static/js/common.js"></script> <script typ

我正在使用HTML5和ant构建脚本,我正在尝试将其集成到我现有的平台中,我所有的css和js文件都使用绝对路径。例如:

             <!-- scripts concatenated and minified via build script -->
        <script type="text/javascript" src="/static/js/common.js"></script>
        <script type="text/javascript" src="/static/js/overlay.js"></script>
        <script type="text/javascript" src="/static/js/init.js"></script>
        <script type="text/javascript" src="/static/js/base.js"></script>
        <!-- end scripts -->
但是,当我运行构建脚本时,它告诉我目录不存在。这是因为它不使用相对路径来查找文件。如果我去掉前导项/则我可以使其工作,因为它相对于我的项目源文件夹。你知道我怎样才能在不删除前导斜杠的情况下让它工作吗?这个想法是能够接受一个现有的项目,并使其工作,除了添加注释外,没有任何更改

更新 以下ANT代码来自HTML5.ANT build.xml。基本上,我在file.root.page中的路径与上面的静态路径相同。因此,scripts.ordered属性输出具有绝对路径的文件名。因此,当它到达concat命令时,它接受script.toconcat的输入,其中包含以/static开头的绝对路径。我需要为这些绝对路径预先设置一个路径,这样我现在就有了/content/test.war/static/js/common.js

因此,基本上,我试图在变量scripts.toconcat前面添加一个路径,比如/content/test.war,在这个变量的后面是上面定义的绝对路径列表

<filelist id="file.root" dir="${dir.source}/../${dir.cssjsfileloc}" files="${file.root.page}"/>
    <echo message="Concatenating Main JS scripts based on ${file.root.page}..."/>
    <apply executable="java" parallel="false"
      outputproperty="scripts.ordered">
        <arg value="-cp"/>
        <arg value="${dir.build.tools}"/>
        <arg value="ScriptsToConcat"/>
        <first>
            <filelist refid="file.root"/>
        </first>
    </apply>
    <filelist id="scripts.toconcat" dir="./${dir.intermediateroot}/" files="${scripts.ordered}">
    </filelist> 
<!-- overwrite=no here means not to overwrite if the target is newer than the sources -->
    <concat destfile="./${dir.intermediate}/${dir.js}/scripts-concat.min.js" overwrite="no">
        <filelist refid="scripts.toconcat" />
    </concat>

谢谢

我是Ant。为什么不让一个在该任务之后运行的Ant任务进行替换呢


您可以调用目录进度任务来搜索和替换文件。

我不想编辑文件的内容。我宁愿直接编辑文件列表。检查上面的ant任务