1

I am using the html5boiler plate ant build scripts and i am trying to integrate this into my existing platform where i all my css and js files are included using absolute paths. For example:

             <!-- 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 -->

However, when i run the build script it tells me the directory does not exist. That is because its not using a relative path to find the files. If i take off the leading / then i can get it to work becuase its relative to my project source folder. Any idea how i can get this working without taking that leading slash off? The idea is to be able to take an existing project and make it work without any changes besides adding the comments in.

UPDATE The following ANT code is from the html5boiler plate ant build.xml. Basically, my paths in the file.root.page are absolute like i static above. Therefore the scripts.ordered property is outputting file names with an absolute path. So when it gets to the concat command it take an input of script.toconcat with are absolute paths starting with /static. I need to prepend a path to those absolute paths so i now have /content/test.war/static/js/common.js

So basically, im trying to prepend a path such as /content/test.war to the variable scripts.toconcat which under the covers is a list of absolute paths defined above.

<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>

Thanks

4

1 回答 1

0

这是蚂蚁。为什么不让 Ant 任务在替换之后运行呢?

您可以调用replaceregexp,它是用于文件搜索和替换的目录节奏任务。

于 2012-12-27T02:38:11.017 回答