api / org.gradle.api.publish.ivy

Package org.gradle.api.publish.ivy

Types

IvyArtifact

interface IvyArtifact : PublicationArtifact

An artifact published as part of a IvyPublication.

IvyArtifactSet

interface IvyArtifactSet : DomainObjectSet<IvyArtifact>

A Collection of IvyArtifacts to be included in an IvyPublication. Being a DomainObjectSet, a IvyArtifactSet provides convenient methods for querying, filtering, and applying actions to the set of IvyArtifacts.

 apply plugin: 'ivy-publish' def publication = publishing.publications.create("my-pub", IvyPublication) def artifacts = publication.artifacts artifacts.matching({ it.type == "source" }).all({ it.extension = "src.jar" }) 

IvyConfiguration

interface IvyConfiguration : Named

A configuration included in an IvyPublication, which will be published in the ivy descriptor file generated.

IvyConfigurationContainer

interface IvyConfigurationContainer : NamedDomainObjectContainer<IvyConfiguration>

The set of IvyConfigurations that will be included in the IvyPublication. Being a org.gradle.api.NamedDomainObjectContainer, a IvyConfigurationContainer provides convenient methods for adding, querying, filtering, and applying actions to the set of IvyConfigurations.

 apply plugin: 'ivy-publish' def publication = publishing.publications.create("my-pub", IvyPublication) def configurations = publication.configurations configurations.create("extended", { extend "default"}) configurations.all { extend "base" } 

IvyDependency

interface IvyDependency

A module dependency declared in an ivy dependency descriptor published as part of an IvyPublication.

IvyExtraInfoSpec

interface IvyExtraInfoSpec : IvyExtraInfo

Represents a modifiable form of IvyExtraInfo so that "extra" info elements can be configured on an Ivy publication.

IvyModuleDescriptorAuthor

interface IvyModuleDescriptorAuthor

An author of an Ivy publication.

IvyModuleDescriptorDescription

interface IvyModuleDescriptorDescription

The description of an Ivy publication.

IvyModuleDescriptorLicense

interface IvyModuleDescriptorLicense

A license of an Ivy publication.

IvyModuleDescriptorSpec

interface IvyModuleDescriptorSpec

The descriptor of any Ivy publication.

Corresponds to the XML version of the Ivy Module Descriptor.

The #withXml(org.gradle.api.Action) method can be used to modify the descriptor after it has been generated according to the publication data. However, the preferred way to customize the project information to be published is to use the dedicated configuration methods exposed by this class, e.g. #description(Action).

IvyPublication

interface IvyPublication : Publication

A IvyPublication is the representation/configuration of how Gradle should publish something in Ivy format, to an Ivy repository. You directly add a named Ivy Publication the project's publishing.publications container by providing IvyPublication as the type.

 publishing { publications { myPublicationName(IvyPublication) { // Configure the publication here } } } 

The Ivy module identifying attributes of the publication are mapped as follows:

  • module - project.name
  • organisation - project.group
  • revision - project.version
  • status - project.status

For certain common use cases, it's often sufficient to specify the component to publish, using (#from(org.gradle.api.component.SoftwareComponent). The published component is used to determine which artifacts to publish, and which configurations and dependencies should be listed in the generated ivy descriptor file.

You can add configurations to the generated ivy descriptor file, by supplying a Closure to the #configurations(org.gradle.api.Action) method.

To add additional artifacts to the set published, use the #artifact(Object) and #artifact(Object, org.gradle.api.Action) methods. You can also completely replace the set of published artifacts using #setArtifacts(Iterable). Together, these methods give you full control over the artifacts to be published.

In addition, IvyModuleDescriptorSpec provides configuration methods to customize licenses, authors, and the description to be published in the Ivy module descriptor.

For any other tweaks to the publication, it is possible to modify the generated Ivy descriptor file prior to publication. This is done using the IvyModuleDescriptorSpec#withXml(org.gradle.api.Action) method, normally via a Closure passed to the #descriptor(org.gradle.api.Action) method.

Example of publishing a java component with an added source jar and custom module description
 apply plugin: "java" apply plugin: "ivy-publish" task sourceJar(type: Jar) { from sourceSets.main.allJava } publishing { publications { myPublication(IvyPublication) { from components.java artifact(sourceJar) { type "source" extension "src.jar" conf "runtime" } descriptor { license { name = "Custom License" } author { name = "Custom Name" } description { text = "Custom Description" } } } } } 

Exceptions

InvalidIvyPublicationException

open class InvalidIvyPublicationException : InvalidUserDataException

Thrown when attempting to publish with an invalid IvyPublication.