[英]HTML 5 Boiler plate ant script with absolute paths
我正在使用html5boiler板蚂蚁构建脚本,并且尝试将其集成到我的现有平台中,其中使用绝对路径将所有我的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代码来自html5boiler板蚂蚁build.xml。 基本上,我在file.root.page中的路径是绝对的,就像我上面的static一样。 因此,scripts.ordered属性将输出带有绝对路径的文件名。 因此,在使用concat命令时,它会输入script.toconcat,其中包含以/ static开头的绝对路径。 我需要在这些绝对路径之前添加一条路径,因此我现在拥有/content/test.war/static/js/common.js
因此,基本上,我试图将诸如/content/test.war之类的路径添加到变量scripts.toconcat的前面,该脚本的内容是上面定义的绝对路径的列表。
<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任务?
您可以调用replaceregexp ,这是目录搜索文件和替换文件的任务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.