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

## org.gradle.api.artifacts.dsl
[Java] Interface ArtifactHandler

    public interface ArtifactHandler

This class is for creating publish artifacts and adding them to configurations. Creating publish artifacts does not mean to create an archive. What is created is a domain object which represents a file to be published and information on how it should be published (e.g. the name). The publish artifact, that should be created, can only be described with an archive at the moment. We will add additional notations in the future.

To create an publish artifact and assign it to a configuration you can use the following syntax:

`<ArtifactHandler>.<configurationName> <artifact-notation>, <artifact-notation> ...` or `<ArtifactHandler>.<configurationName> <artifact-notation> { ... some code to configure the artifact }`

The notation can be one of the following types:

- AbstractArchiveTask. The information for publishing the artifact is extracted from the archive task (e.g. name, extension, ...). An archive artifact is represented using an instance of PublishArtifact.
- java.io.File. The information for publishing the artifact is extracted from the file name. You can tweak the resulting values by using a closure to configure the properties of the artifact instance. A file artifact is represented using an instance of ConfigurablePublishArtifact

## Examples

An example showing how to associate an archive task with a configuration via the artifact handler. This way the archive can be published or referred in other projects via the configuration.

     configurations {
       //declaring new configuration that will be used to associate with artifacts
       schema
     }

     task schemaJar(type: Jar) {
       //some imaginary task that creates a jar artifact with some schema
     }

     //associating the task that produces the artifact with the configuration
     artifacts {
       //configuration name and the task:
       schema schemaJar
     }

Authors:
  Hans Dockter

Method Summary
`PublishArtifact` | `add(java.lang.String configurationName, java.lang.Object artifactNotation)` Adds an artifact to the given configuration.
`PublishArtifact` | `add(java.lang.String configurationName, java.lang.Object artifactNotation, groovy.lang.Closure configureClosure)` Adds an artifact to the given configuration.

Method Detail

### add

    public PublishArtifact add(java.lang.String configurationName, java.lang.Object artifactNotation)

  Adds an artifact to the given configuration.
  Parameters:
    `configurationName` - The name of the configuration.
    `artifactNotation` - The artifact notation, in one of the notations described above.
  Returns:
    The artifact.

### add

    public PublishArtifact add(java.lang.String configurationName, java.lang.Object artifactNotation, groovy.lang.Closure configureClosure)

  Adds an artifact to the given configuration.
  Parameters:
    `configurationName` - The name of the configuration.
    `artifactNotation` - The artifact notation, in one of the notations described above.
    `configureClosure` - The closure to execute to configure the artifact.
  Returns:
    The artifact.

Groovy Documentation