ArtifactHandler

This class is for defining artifacts to be published 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).

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:

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

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
}

Functions

Link copied to clipboard
abstract fun add(configurationName: String, artifactNotation: Any): PublishArtifact
abstract fun add(configurationName: String, artifactNotation: Any, @DelegatesTo(value = ConfigurablePublishArtifact::class) configureClosure: Closure): PublishArtifact
abstract fun add(configurationName: String, artifactNotation: Any, configureAction: Action<in ConfigurablePublishArtifact>): PublishArtifact
Adds an artifact to the given configuration.
Link copied to clipboard
operator fun ArtifactHandler.invoke(configuration: ArtifactHandlerScope.() -> Unit)

Configures the published artifacts for this project.