Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD

## org.gradle.api.file
Interface FileCollection

    interface FileCollection
    extends java.lang.Iterable

A `FileCollection` represents a collection of files which you can query in certain ways. A file collection is often used to define a classpath, or to add files to a container.

You can obtain a `FileCollection` instance using org.gradle.api.Project#files.

Nested Class Summary
`enum` | `FileCollection.AntType`

Method Summary
`FileCollection` | `add(FileCollection collection)` Adds another collection to this collection.
`void` | `addToAntBuilder(java.lang.Object builder, java.lang.String nodeName, AntType type)` A {
`java.lang.Object` | `addToAntBuilder(java.lang.Object builder, java.lang.String nodeName)` Adds this collection to an Ant task as a nested node.
`java.lang.Object` | `asType(java.lang.Class type)` Converts this collection into an object of the specified type.
`FileTree` | `getAsFileTree()` Converts this collection to a {
`java.lang.String` | `getAsPath()` Returns the contents of this collection as a platform-specific path.
`Set` | `getFiles()` Returns the contents of this collection as a Set.
`File` | `getSingleFile()` Returns the content of this collection, asserting it contains exactly one file.
`FileCollection` | `plus(FileCollection collection)` Returns a {
`FileCollection` | `stopExecutionIfEmpty()` Throws a {
`FileCollection` | `valueOf(java.lang.String name)` Returns the enum constant of this type with the specified name.
`FileCollection[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

Methods inherited from interface java.lang.Iterable
iterator

Methods inherited from class java.lang.Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll

Method Detail

### add

    public FileCollection add(FileCollection collection)

  Adds another collection to this collection. This is an optional operation.

  param:
    collection The collection to add.
  return:
    This
  throws:
    UnsupportedOperationException When this collection does not alow modification.

### addToAntBuilder

    public void addToAntBuilder(java.lang.Object builder, java.lang.String nodeName, AntType type)

  A `FileCollection` represents a collection of files which you can query in certain ways. A file collection is often used to define a classpath, or to add files to a container.

  You can obtain a `FileCollection` instance using org.gradle.api.Project#files.

### addToAntBuilder

    public java.lang.Object addToAntBuilder(java.lang.Object builder, java.lang.String nodeName)

  Adds this collection to an Ant task as a nested node. Equivalent to calling `addToAntBuilder(builder, nodeName,AntType.ResourceCollection)`.

### asType

    public java.lang.Object asType(java.lang.Class type)

  Converts this collection into an object of the specified type. Supported types are: `Collection`, `List`, `Set`, `Object[]`, `File[]`, and `File`.

  You can call this method in your build script using the `as` operator.

  param:
    type The type to convert to.
  return:
    The converted value.
  throws:
    UnsupportedOperationException When an unsupported type is specified.

### getAsFileTree

    public FileTree getAsFileTree()

  Converts this collection to a FileTree.
  return:
    this collection as a FileTree. Never returns null.

### getAsPath

    public java.lang.String getAsPath()

  Returns the contents of this collection as a platform-specific path. This can be used, for example, in an Ant element.
  return:
    The path. Returns an empty string if this collection is empty.

### getFiles

    public Set getFiles()

  Returns the contents of this collection as a Set.
  return:
    The files. Returns an empty set if this collection is empty.

### getSingleFile

    public File getSingleFile()

  Returns the content of this collection, asserting it contains exactly one file.
  return:
    The file.
  throws:
    IllegalStateException when this collection does not contain exactly one file.

### plus

    public FileCollection plus(FileCollection collection)

  Returns a `FileCollection` which contains the union of this collection and the given collection. The returned collection is live, and tracks changes to both source collections.

  You can call this method in your build script using the + operator.

  param:
    collection The other collection. Should not be null.
  return:
    A new collection containing the union.

### stopExecutionIfEmpty

    public FileCollection stopExecutionIfEmpty()

  Throws a StopExecutionException if this collection is empty.
  return:
    this
  throws:
    StopExecutionException When this collection is empty.

### valueOf

    FileCollection valueOf(java.lang.String name)

  Returns the enum constant of this type with the specified name.

### values

    FileCollection[] values()

  Returns an array containing the constants of this enum type, in the order they are declared.

Groovy Documentation