WeaverFileList

Description

This task is similar to WeaverFileSet, except instead of storing the artifacts in an Ant FileSet variable, files are stored in a comma-delimited string. The motivation for using this task is that FileSets do not preserve ordering. It is sometimes useful to obtain a list of artifacts sorted in dependency order (e.g. to build projects in the order of dependency).

Note: the comma-delimited list of files will be relative paths, relative the ‘dir’ attribute declared in the WeaverProjects task.

Parameters

Attribute Description Required
property Name of Ant property to instantiate. Yes
type This specifies the type of artifact that the FileSet will contain. This value corresponds to the ‘type’ attribute for the ‘artifact’ nested element in WeaverProjects task. Yes
project This specifies the root project that will be used to obtain the artifacts. Starting at this root, the dependency graph will traversed and all artifacts of all project dependencies will be included in the FileSet. No. Defaults to all projects registered with WeaverProjects.
inclusive If set to ‘true’, then the FileSet created will include artifacts for the declared project. Otherwise, the FileSet will only contain artifacts for the dependency projects of the declared project. This attribute is ignored if the ‘project’ attribute is not declared. No. Defaults to ‘false’.

Examples

All of the examples below assume that the following WeaverProjects task instantiation has been declared:

<weaverProjects dir="c:/cvslocal/root">
  <project name="client" depends="common">
    <artifact type="build.file" file="projects/webapp/client/build.xml"/>
    <artifact type="jar" file="repository/client.jar"/>
  </project>
  <project name="common">
    <artifact type="build.file" file="projects/webapp/common/build.xml"/>
    <artifact type="jar" file="repository/common.jar"/>
  </project>
  <project name="server" depends="common">
    <artifact type="build.file" file="projects/webapp/server/build.xml"/>
    <artifact type="jar" file="repository/server.jar"/>
  </project>
</weaverProjects>

Example 1

<weaverFileList property="server.build.files" project="server" type="build.file"/>
<for list="${server.build.files}" param="file">
  <sequential>
    <echo message="c:/cvslocal/root/@{file}"/>
  </sequential>
</for>

The call to ‘WeaverFileList’ creates an Ant property variable with the name ‘server.build.files’. A call to Ant-Contrib task ‘for’ is used to iterate over this property, outputing the absolute path of ‘common/build.xml’ to the screen. The ‘server/build.xml’ file is not displayed, since the optional attribute ‘inclusive’ has not been set, and by default it is ‘false’.

Example 2

<weaverFileList property="inclusive.server.jar.files" inclusive="true" project="server" type="jar"/>
<for list="${inclusive.server.jar.files}" param="file">
  <sequential>
    <echo message="c:/cvslocal/root/@{file}"/>
  </sequential>
</for>

This example is similar to the previous one, except we’re specifying ‘type’ equal to ‘jar’, rather than ‘build.files’. Also, we’ve set ‘inclusive’ to ‘true’. The result is that the absolute paths of ‘common.jar’ and ‘server.jar’ will be displayed.

Example 3

<weaverFileList property="all.build.files" type="build.file"/>
<for list="${all.build.files}" param="file">
  <sequential>
    <echo message="c:/cvslocal/root/@{file}"/>
  </sequential>
</for>

In this example, the ‘project’ attribute is not declared. This causes the ‘WeaverFileList’ to include all projects. The result is that the absolute paths of the build files for all three projects will be output.

It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply