From 94cf2091bf31699ddc134c311c8d8a567d7826ab Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Tue, 29 Dec 2009 18:22:59 +0000 Subject: [PATCH] document resourcelist and make it available git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@894459 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 3 + docs/manual/CoreTypes/resources.html | 81 +++++++++++++++++++ .../types/resources/resourcelist.xml | 2 - .../tools/ant/types/defaults.properties | 1 + .../types/resources/resourcelist-test.xml | 2 - 5 files changed, 85 insertions(+), 4 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 204af08f7..5e3aa5114 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -1034,6 +1034,9 @@ Other changes: collections. Bugzilla Report 22269. + * a new type is similar to but can read the + list of resources from non-file resources and may return resources + that are not files. Changes from Ant 1.7.0 TO Ant 1.7.1 ============================================= diff --git a/docs/manual/CoreTypes/resources.html b/docs/manual/CoreTypes/resources.html index 37c9345a7..21969801e 100644 --- a/docs/manual/CoreTypes/resources.html +++ b/docs/manual/CoreTypes/resources.html @@ -371,6 +371,8 @@ Ant's "legacy" datatypes have been modified to behave as Resource Collections:
  • archives - wraps around different resource collections and treats the nested resources as ZIP or TAR archives that will be extracted on the fly.
  • +
  • resourcelist - a collection of + resources who's names have been read from another resource.
  • resources

    A generic resource collection, designed for use with @@ -1068,6 +1070,8 @@ larger collection. Since Ant 1.7.1.

    mappedresources

    +

    Since Ant 1.8.0

    +

    Wraps another resource collection and maps the names of the nested resources using a mapper.

    @@ -1123,6 +1127,8 @@ larger collection. Since Ant 1.7.1.

    archives

    +

    Since Ant 1.8.0

    +

    This resource collection accepts an arbitrary number of nested resources and assumes that all those resources must be either ZIP or TAR archives. The resources returned @@ -1166,5 +1172,80 @@ larger collection. Since Ant 1.7.1.

    +

    resourcelist

    + +

    Since Ant 1.8.0

    + +

    This resource collection accepts an arbitrary number of nested + resources, reads those resources and returns a resource for each + line read.

    + +

    If the line contains a colon, Ant will try to use it as an URL and + if that fails (or the line doesn't contain a colon) will return a + file resource with the line's content as its name.

    + +

    Properties will be expanded for each line. If the property + expansion yields a resource object rather than a string (for example + because of custom property helpers), the resources will be returned + directly.

    + +

    <resourcelist> is a generalization + of <filelist>.

    + +
    + + + + + + + + + + + +
    AttributeDescriptionRequired
    encodingThe encoding of the nested resourcesNo, default is platform default
    +
    + +
    +

    Parameters specified as nested elements

    + +

    <resourcelist> accepts arbitrary many + resource(collection)s as nested elements.

    + +

    In addition <resourcelist> supports + nested <filterchain> elements that can be used + to filter/modify the read resources before their lines get + expanded. Such a nested element corresponds to + a filterchain.

    + +

    Examples

    + +

    The following example copies a file from the first URL of + several alternatives that can actually be reached. It assumes + that the file mirrors.txt looks like

    + +
    +    mirrors.txt:
    +http://best.mirror.example.org/
    +http://second.best.mirror.example.org/mirror/of/best/
    +https://yet.another.mirror/
    +http://the.original.site/
    +  
    + +
    +    <copy todir="${target}">
    +      <first>
    +        <restrict>
    +          <resourcelist>
    +            <file file="mirrors.txt"/>
    +          </resourcelist>
    +          <exists/>
    +        </restrict>
    +      </first>
    +    </copy>
    +  
    +
    + diff --git a/src/etc/testcases/types/resources/resourcelist.xml b/src/etc/testcases/types/resources/resourcelist.xml index 6b5951914..f1ac6df74 100644 --- a/src/etc/testcases/types/resources/resourcelist.xml +++ b/src/etc/testcases/types/resources/resourcelist.xml @@ -21,8 +21,6 @@ - diff --git a/src/main/org/apache/tools/ant/types/defaults.properties b/src/main/org/apache/tools/ant/types/defaults.properties index 91bc4f62d..acd064615 100644 --- a/src/main/org/apache/tools/ant/types/defaults.properties +++ b/src/main/org/apache/tools/ant/types/defaults.properties @@ -76,6 +76,7 @@ tarfileset=org.apache.tools.ant.types.TarFileSet tokens=org.apache.tools.ant.types.resources.Tokens mappedresources=org.apache.tools.ant.types.resources.MappedResourceCollection archives=org.apache.tools.ant.types.resources.Archives +resourcelist=org.apache.tools.ant.types.resources.ResourceList #Resources (single-element ResourceCollections): resource=org.apache.tools.ant.types.Resource diff --git a/src/tests/antunit/types/resources/resourcelist-test.xml b/src/tests/antunit/types/resources/resourcelist-test.xml index daa847dc8..37c77a0c2 100644 --- a/src/tests/antunit/types/resources/resourcelist-test.xml +++ b/src/tests/antunit/types/resources/resourcelist-test.xml @@ -22,8 +22,6 @@ -