I now see Ant has both an <include>
task and an <import>
task.
According to the descriptions:
Include
Include another build file into the current project.
and
Import
Imports another build file into the current project.
So, why use one over the other?
Here's my actual problem:
In our current build system, we are concatenating a bunch of JavaScripts and then minimizing them. The JavaScripts are located in a dozen different directories, and we are taking batches from each directory and concatenating them into five or six super minimized JavaScripts. Some of these files are copied into multiple super JavaScripts.
In order to make debugging easier, and the build a bit more flexible, I want to copy all of the files into the target/work/resources2
directory with each sub-directory under there representing a different super minimized JavaScript. For debugging purposes, we'll include the non-minimized super JavaScript and the originals. The build script isn't complex, but the whole section is taking up a lot of lines. I was thinking of putting the <copy>
stuff into a separate XML file, so the whole thing looks like this:
<target name="process-resources"
description="Concatenate and minimize the JavaScripts (using Maven lifecycle names for our targets">
<!-- The following include the copying stuff -->
<here.be.dragons file="${basedir}/reservations.xml"/>
<here.be.dragons file="${basedir}/date.xml"/>
<here.be.dragons file="${basedir}/select.xml"/>
<for param="concat.dir">
<fileset dir="${work.dir]/resources2"/>
<sequential>
<here.I.am.concatenating.and.minimizing/>
</sequential>
</for>
</target>
I see there are four possibilities:
- Use
<ant/>
to call the files that do the copying - Use
<import/>
(which might not work because it might not be able to be included inside a target) - Use
<include/>
(which might not work because it might not be able to be included inside a target) - Use the Entity Include.
I am never crazy about using <ant/>
or <antcall>
although this might be a good time to do this. The Entity Include idea will work, but that's something most people don't understand, and I am afraid it will cause confusion for people who have to support what I'm doing. The <import>
and <include>
may not be able to be used in this situation, but I'm still curious what the differences are.
The documentation of import explains the difference:
How is import different from include?