concept custom resource in category ant

appears as: custom resource, custom resources
Ant in Action

This is an excerpt from Manning's book Ant in Action.

  • Writing custom resources, filters, selectors, and mappers
  • 18.3. Writing a custom resource

    One very interesting extension point to Ant is the resource class hierarchy. In chapter 17, we resource-enabled our <filesize> task, so it could process data from any resource. Equally powerful is that the resource type itself can be extended. To do this, we extend the org.apache.tools.ant.types.Resource class with a custom resource class, overriding the base methods. The key method to override is usually getInputStream(), which returns the contents of the resource as input stream. There are some other methods that can be useful to override, specifically getLastModified() and getSize(). These methods return the timestamp of the resource (or 0L if it isn’t known) and the resource size, respectively. The base class actually has setSize() and setLastModified() methods that can be used in build files to set the values; this may be adequate for the custom resource.