# IvyPublication

interface IvyPublication : Publication(source)

An `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
        }
      }
    }

Content copied to clipboard

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. 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 method.

To add additional artifacts to the set published, use the artifact and artifact methods. You can also completely replace the set of published artifacts using setArtifacts. 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 withXml method, normally via a Closure passed to the descriptor method.

    // Example of publishing a java component with an added source jar and custom module description
    plugins {
        id 'java'
        id '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"
            }
          }
        }
      }
    }

Content copied to clipboard

#### Since

1.3

## Functions

artifact
Link copied to clipboard
abstract fun artifact(source: Any): IvyArtifact
Creates a custom IvyArtifact to be included in the publication.
abstract fun artifact(source: Any, config: Action<in IvyArtifact>): IvyArtifact
Creates an IvyArtifact to be included in the publication, which is configured by the associated action.
configurations
Link copied to clipboard
abstract fun configurations(config: Action<in IvyConfigurationContainer>)
Defines some IvyConfigurations that should be included in the published ivy module descriptor file.
descriptor
Link copied to clipboard
abstract fun descriptor(configure: Action<in IvyModuleDescriptorSpec>)
Configures the descriptor that will be published.
from
Link copied to clipboard
abstract fun from(component: SoftwareComponent)
Provides the software component that should be published.
getArtifacts
Link copied to clipboard
abstract fun getArtifacts(): IvyArtifactSet
The complete set of artifacts for this publication.
getConfigurations
Link copied to clipboard
abstract fun getConfigurations(): IvyConfigurationContainer
Returns the complete set of configurations for this publication.
getDescriptor
Link copied to clipboard
abstract fun getDescriptor(): IvyModuleDescriptorSpec
The module descriptor that will be published.
getModule
Link copied to clipboard
abstract fun getModule(): String
Returns the module for this publication.
getName
Link copied to clipboard
abstract fun getName(): String
The object's name.
getOrganisation
Link copied to clipboard
abstract fun getOrganisation(): String
Returns the organisation for this publication.
getRevision
Link copied to clipboard
abstract fun getRevision(): String
Returns the revision for this publication.
setArtifacts
Link copied to clipboard
abstract fun setArtifacts(sources: Iterable<out Any>)
Sets the artifacts for this publication.
setModule
Link copied to clipboard
abstract fun setModule(module: String)
Sets the module for this publication.
setOrganisation
Link copied to clipboard
abstract fun setOrganisation(organisation: String)
Sets the organisation for this publication.
setRevision
Link copied to clipboard
abstract fun setRevision(revision: String)
Sets the revision for this publication.
suppressAllIvyMetadataWarnings
Link copied to clipboard
abstract fun suppressAllIvyMetadataWarnings()
Silences all the compatibility warnings for the Ivy publication.
suppressIvyMetadataWarningsFor
Link copied to clipboard
abstract fun suppressIvyMetadataWarningsFor(variantName: String)
Silences the compatibility warnings for the Ivy publication for the specified variant.
versionMapping
Link copied to clipboard
abstract fun versionMapping(configureAction: Action<in VersionMappingStrategy>)
Configures the version mapping strategy.
withBuildIdentifier
Link copied to clipboard
abstract fun withBuildIdentifier()
Enables publication of a unique build identifier in Gradle Module Metadata.
withoutBuildIdentifier
Link copied to clipboard
abstract fun withoutBuildIdentifier()
Disables publication of a unique build identifier in Gradle Module Metadata.