public interface ArtifactHandler
To create an publish artifact and assign it to a configuration you can use the following syntax:
<configurationName> <artifact-notation>, <artifact-notation> ...
or
<configurationName> <artifact-notation> { ... some code to configure the artifact }
The notation can be one of the following types:
PublishArtifact
.AbstractArchiveTask
. The information for publishing the artifact is extracted from the archive task (e.g. name, extension, ...). The task will be executed if the artifact is required.Provider
of File
, RegularFile
or Directory
. The information for publishing the artifact is extracted from the file or directory name. When the provider represents an output of a particular task, that task will be executed if the artifact is required.File
. The information for publishing the artifact is extracted from the file name.Map
. The map should contain a 'file' key. This is converted to an artifact as described above. You can also specify other properties of the artifact using entries in the map.
In each case, a ConfigurablePublishArtifact
instance is created for the artifact, to allow artifact properties to be configured. You can also override the default values for artifact properties by using a closure to configure the properties of the artifact instance
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 }
Modifier and Type | Method and Description |
---|---|
PublishArtifact |
add(String configurationName,
Object artifactNotation)
Adds an artifact to the given configuration.
|
PublishArtifact |
add(String configurationName,
Object artifactNotation,
Action<? super ConfigurablePublishArtifact> configureAction)
Adds an artifact to the given configuration.
|
PublishArtifact |
add(String configurationName,
Object artifactNotation,
Closure configureClosure)
Adds an artifact to the given configuration.
|
PublishArtifact add(String configurationName, Object artifactNotation)
configurationName
- The name of the configuration.artifactNotation
- The artifact notation, in one of the notations described above.PublishArtifact add(String configurationName, Object artifactNotation, Closure configureClosure)
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.PublishArtifact add(String configurationName, Object artifactNotation, Action<? super ConfigurablePublishArtifact> configureAction)
configurationName
- The name of the configuration.artifactNotation
- The artifact notation, in one of the notations described above.configureAction
- The action to execute to configure the artifact.