Skip to content
This repository has been archived by the owner on Nov 23, 2018. It is now read-only.

How to bypass the automatic script concatenation

roblarsen edited this page Jan 8, 2013 · 2 revisions

To bypass the automatic script concatenation in cases where you have a dynamic path, all you need to do is swap out the automatic js.main.concat target for one that uses a manual <filelist>`````` element combination.

As of this writing the code is at lines 453 through 497

All you need to do is uncomment the alternative task and add your files, in order, as children of the <filelist> element. For example:

    <target name="-js.main.concat" depends="-js.all.minify" description="(PRIVATE) Concatenates the JS files in dir.js">
        <filelist id="scripts.toconcat" dir="./${dir.intermediate}/">
          <file name="plugins.js"/>
          <file name="scripts.js"/>
          <file name="foo.js"/>
          <file name="bar.js"/>
      </filelist>
        
        <concat destfile="./${dir.intermediate}/${dir.js}/scripts-concat.min.js" overwrite="no">
            <filelist refid="scripts.toconcat"/>
        </concat>
    </target>

And then comment out or delete the default target

    <target name="-js.main.concat" depends="-js.all.minify" description="(PRIVATE) Concatenates the JS files in dir.js">
        <filelist id="file.root" dir="${dir.source}" 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.intermediate}/" files="${scripts.ordered}">
        </filelist>
        
        <concat destfile="./${dir.intermediate}/${dir.js}/scripts-concat.min.js" overwrite="no">
            <filelist refid="scripts.toconcat"/>
        </concat>
    </target>

Everything else should work exactly the same.